convert -resize sometimes produces one-colored images

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

convert -resize sometimes produces one-colored images

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert -resize sometimes produces one-colored images

Post 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.
snibgo's IM pages: im.snibgo.com
mack3457
Posts: 10
Joined: 2012-10-21T01:12:07-07:00
Authentication code: 67789

Re: convert -resize sometimes produces one-colored images

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: convert -resize sometimes produces one-colored images

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

Re: convert -resize sometimes produces one-colored images

Post by mack3457 »

Great - thank you!

Thomas Mack
Post Reply