loose transparency when draw black on transparent background

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
peter_werk
Posts: 1
Joined: 2011-04-15T05:42:07-07:00
Authentication code: 8675308

loose transparency when draw black on transparent background

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: loose transparency when draw black on transparent backgr

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply