I have been attempting to write a script using Image::Magick that will place one image on top of another image. Everything works fine except I cannot figure out a way to control to opacity level of the top image. My intention is to be able to speicify how see through the top image (watermark) is. The way it works now is it is completely opaque except for any color that is white. I can make that transparent but not translucent. so many attributes, so little time! There is an opacity attribut i can pass in to the Composite function but only seems to affect the background image? I need to alter the top image's opacity.
my $background=Image::Magick->new(magick=>"gif");
$background->BlobToImage($binary_data);
my $foreground=Image::Magick->new;
$foreground->Read($watermark_file);
$foreground->Transparent(color=>"white");
$background->Composite(compose=>'Over', Image=>$foreground, x=> 1,
+ y=> 1)
$background->Write("gif-");
$binary_data = $background->ImageToBlob();
print "content-type: image/gif\n\n";
print $binary_data;
thanks for the help ahead of time.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.