possible bug preserving color after append

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
User avatar
fmw42
Posts: 25949
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug preserving color after append

Post by fmw42 »

I am having difficulty preserving a color image after appending a bilevel image with two color images (only when the bilevel image is first in the list). What am I doing wrong or is this a bug?

Code: Select all

convert rose: -compress none rose.tif
Image

Code: Select all

convert rose: -threshold 25% rose_t25.png
Image


These two following appends produce a grayscale result rather than color (for the last two images).

Code: Select all

convert rose_t25.png rose.tif rose.tif -append -type truecolor -define png:color-type=2 PNG24:rose_append.png
Image

Code: Select all

convert rose_t25.png rose.tif rose.tif -append -type truecolor -compress lzw rose_append.tif
Image


Whereas the following works if the bilevel image is not first:

Code: Select all

convert rose.tif rose_t25.png rose.tif -append rose_append2.png
Image



Mac OSX Snow Leopard

Code: Select all

convert -version
Version: ImageMagick 6.9.3-2 Q16 x86_64 2016-01-27 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP 
Delegates (built-in): bzlib cairo fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps rsvg tiff webp x xml zlib

User avatar
magick
Site Admin
Posts: 11127
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug preserving color after append

Post by magick »

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.

BzzBzz
Posts: 5
Joined: 2016-09-05T22:23:30-07:00
Authentication code: 1151

Re: possible bug preserving color after append

Post by BzzBzz »

Hello. I will bump this thread to report this bug still exist (partially at least) in IM 6.9.5
Edit: not sure if it's same bug, but looks similar to me.

I want to merge 24-bit color "color.jpg" and 8-bit grayscale "gray.jpg" into single image.

When I do

Code: Select all

convert +append color.jpg gray.jpg out.jpg
There's no problem and resulting image is 24-bit color JPEG image.

Problems starts if first image is grayscale

Code: Select all

convert +append gray.jpg color.jpg out.jpg
Result is 8-bit grayscale JPEG. <== bug!

However there's no problems if I use PNG for output.

Code: Select all

convert +append gray.jpg color.jpg out.png
Result is 24-bit color PNG. <== ok.


Win7 x64, Cygwin

Code: Select all

convert --version

Version: ImageMagick 6.9.5-7 Q16 x86_64 2016-08-27 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC OpenMP
Delegates (built-in): autotrace bzlib cairo fftw fontconfig fpx freetype gslib jbig jng jp2 jpeg lzma pangocairo png ps rsvg tiff webp x xml zlib

User avatar
fmw42
Posts: 25949
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug preserving color after append

Post by fmw42 »

try reading the input images before the +append followed by the output image. The proper IM 6 syntax is to read the inputs, then the settings, then the operators, then the output. See http://www.imagemagick.org/Usage/basics/#why

This works fine for me on IM 6.9.6.6 Q16 Mac OSX

Code: Select all

convert \( rose: -colorspace gray \) rose: +append test.png
It also works fine for me in IM 6.9.6.5 Q16 Mac OSX

BzzBzz
Posts: 5
Joined: 2016-09-05T22:23:30-07:00
Authentication code: 1151

Re: possible bug preserving color after append

Post by BzzBzz »

Nope.

Code: Select all

convert gray.jpg color.jpg +append out.jpg
Still results in 8-bit jpeg.

There's no bug if output set to png, bmp or tif, I even tried archaic pcx. For some reason only JPEG output is bugged.

Try this (I only changed output format in your example) and it will bug out.

Code: Select all

convert \( rose: -colorspace gray \) rose: +append test.JPG

User avatar
fmw42
Posts: 25949
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug preserving color after append

Post by fmw42 »

You are correct. It fails for jpg output.

Code: Select all

convert \( rose: -colorspace gray \) rose: +append test.jpg
However, this works

Code: Select all

convert \( rose: -colorspace gray \) rose: +append -type truecolor test.jpg
But I think it is still a bug. One should not have to force type=truecolor. It should use the highest color depth automatically, in my opinion. However, often IM will take the settings from the first image in the sequence. But if it works automatically for PNG, TIFF, then it should also do so for JPG (my opinion).

User avatar
magick
Site Admin
Posts: 11127
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug preserving color after append

Post by magick »

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.

Post Reply