Page 1 of 1

loose transparency when draw black on transparent background

Posted: 2011-04-15T05:59:36-07:00
by peter_werk
When I process a image, consisting of a black painting on transparent background,
resulting image will be completely black -> transparency seems to get lost.
This issue happens at processing following formats: GIF and PNG.
Do you have any idea?

system:
imagemagick/hardy uptodate 7:6.3.7.9.dfsg1-2ubuntu1.2
libmagick10/hardy uptodate 7:6.3.7.9.dfsg1-2ubuntu1.2
perlmagick/hardy uptodate 7:6.3.7.9.dfsg1-2ubuntu1.2

Here are my processing steps: read, resize, write

my $image = new Image::Magick;
$image->Read($upload_path);
my $x=$image->Get('width')||0;
my $y=$image->Get('height')||0;
if ($x>0 && $y>0){
if ($x>$y){
$image->Resize(width=>'600', height=>int(600*$y/$x) );
}else{
$image->Resize(width=>int(600*$x/$y), height=>'600' );
}
}
$image->Write('jpg:'.$image_path);

There are no problems with other source images.

Cheers, Peter

Re: loose transparency when draw black on transparent backgr

Posted: 2011-04-17T18:58:03-07:00
by anthony
You are writing to JPEG!

JPEG does nto handle transparency!

See IM Examples, Jpeg transparency - NOT!
http://www.imagemagick.org/Usage/formats/#jpg_trans
For Solutions see Removing Transparency
http://www.imagemagick.org/Usage/masking/#remove