Page 1 of 1

convert -resize sometimes produces one-colored images

Posted: 2015-01-11T03:11:05-07:00
by mack3457
Resizing images sometimes reduces colors to just one color. This depend on the input file and the size reduction.

Running:

Code: Select all

for f in $(seq 1 1000); do convert in.tif -verbose -resize x$f out.gif; done
produces output like this:

Code: Select all

[...]
in.tif=>out.gif TIFF 7027x5426=>263x203 263x203+0+0 8-bit Palette sRGB 116c 44KB 0.000u 0:00.000
in.tif=>out.gif TIFF 7027x5426=>264x204 264x204+0+0 8-bit Palette sRGB 115c 44.3KB 0.000u 0:00.000
in.tif=>out.gif TIFF 7027x5426=>265x205 265x205+0+0 8-bit Palette sRGB 1c 356B 0.000u 0:00.000
in.tif=>out.gif TIFF 7027x5426=>267x206 267x206+0+0 8-bit Palette sRGB 121c 45.3KB 0.000u 0:00.000
in.tif=>out.gif TIFF 7027x5426=>268x207 268x207+0+0 8-bit Palette sRGB 115c 45.3KB 0.000u 0:00.000
in.tif=>out.gif TIFF 7027x5426=>269x208 269x208+0+0 8-bit Palette sRGB 115c 46KB 0.000u 0:00.000
in.tif=>out.gif TIFF 7027x5426=>271x209 271x209+0+0 8-bit Palette sRGB 120c 46.5KB 0.000u 0:00.000
[...]
The problem started with version 6.9.0-2, 6.9.0-0 was still fine.

Tests on different machines and with convert or PerlMagick gave me different amount of problematic resize sizes. Most problems I had with PerlMagick and use of the CGI module on a FreeBSD 10.1 server (about 88 one color images for 1000 sizes). Less problems when not using the CGI module(???) (about 69) and still less when using convert or system(convert -resize ...) (about 2 images with one color only).

So for now I revert to system calls, but they aren't save as well.

Did anyone observe similar behaviour?

Thomas Mack

Re: convert -resize sometimes produces one-colored images

Posted: 2015-01-11T04:06:51-07:00
by snibgo
For someone to investigate, please provide an input file that shows the problem. You can put it somewhere like dropbox.com and paste the link here.

Re: convert -resize sometimes produces one-colored images

Posted: 2015-01-11T07:09:05-07:00
by mack3457
Oh yes.
I tested with http://th-mack.de/download/test/in.tif .

Problems on 6.9.0-2 / FreeBSD 10.1 e.g. on -resize x135 and x303 when using convert directly.

When using in PerlMagick, many more:

Code: Select all

#!/usr/bin/perl
use Image::Magick;

for(1..400) {
        my $image = Image::Magick->new;
        $image->Read("in.tif");
        $image->Resize(geometry=>"x$_");
        $image->Set(verbose=>'True');
        print $image->Write("out.gif");
        undef $image;
}
6.9.0-2 on Ubuntu: varying problems depending on the installation, it seems. I had an installation, where the problem appeared as minimum 9 colors on output, while neighbouring resize sizes used about 70 to 80 colors. Did a new installation of 6.0.9-2 and now have the '1c' output twice again.

Re: convert -resize sometimes produces one-colored images

Posted: 2015-01-11T07:16:09-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.9.0-4 Beta, available by sometime tomorrow. Thanks.

Re: convert -resize sometimes produces one-colored images

Posted: 2015-01-11T08:38:23-07:00
by mack3457
Great - thank you!

Thomas Mack