Page 1 of 1

Transparent image after scale

Posted: 2018-02-23T07:23:51-07:00
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

Re: Transparent image after scale

Posted: 2018-02-23T08:22:14-07:00
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%.

Re: Transparent image after scale

Posted: 2018-02-23T08:38:52-07:00
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