Transparent image after scale

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
mack3457
Posts: 10
Joined: 2012-10-21T01:12:07-07:00
Authentication code: 67789

Transparent image after scale

Post by mack3457 »

I found some images on our website, where the scaled version of a non-transparent image was completely transparent without any other content. Is this a possible bug or did I completely misunderstand something about it?

I placed one such image on http://th-mack.de/download/bugs/im02.tif for testing.

The command used is:

convert im02.tif -scale 600x400 im02.gif

We have this problem both on Ubuntu 17.10 with:

Code: Select all

Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP 
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib
and FreeBSD 11.1 with:

Code: Select all

Version: ImageMagick 6.9.9-28 Q16 amd64 2018-01-20 http://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules 
Delegates (built-in): bzlib cairo fftw fontconfig freetype jbig jng jp2 jpeg lcms lqr ltdl lzma png raw rsvg tiff webp wmf x xml zlib
Thanks
Thomas Mack
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Transparent image after scale

Post by snibgo »

Your sample image is too large (52MB) for me to download, sorry.

GIF has binary transparency: each pixel is either opaque or transparent. If your resized TIFF image has graduated transparency, I suggest you either flatten it against a background colour, or threshold the alpha channel at 50%.
snibgo's IM pages: im.snibgo.com
mack3457
Posts: 10
Joined: 2012-10-21T01:12:07-07:00
Authentication code: 67789

Re: Transparent image after scale

Post by mack3457 »

Ok, found the reason. The geometry of the original file had an offset:

Code: Select all

  Page geometry: 5100x7000+5100+0
  Origin geometry: +5100+0
The solution was to use:

Code: Select all

convert im02.tif -scale 600x400 +repage im02.gif
Thanks,
Thomas Mack
Post Reply