Very Slow TIFF->GIF conversion

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
mr_walsh

Very Slow TIFF->GIF conversion

Post by mr_walsh »

When I convert a monochrome TIFF file to a GIF, it takes around *7 seconds*.

Converting to a JPG is done in under a second.

The only clue I have is if I use the -monitor flag I see it taking 3 seconds each for the 'Classify image colors' and 'Dither image colors' steps (see below).

I guess I don't get it since the image is monochrome! Why would it take time to classify 2 colors, or to dither when there's nothing to dither! I even tried to be 100% sure by converting the TIFF to monochrome first, but got the same results.

Help!

Is there some way to really force it to not play with the colors?

Code: Select all

convert -monitor -monochrome t2.tiff blah.gif
Load image: 100%
Classify image colors: 100%
Dither image colors: 100%
Save image: 100%
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Very Slow TIFF->GIF conversion

Post by anthony »

Must be a VERY big image. GIF is a limited format with only 256 colors IM has to do a LOT of work to find the best colors to use, based on all the colors in the original image, and then replace all the pixel colors with an appropriate dither pattern on those colors. Basically this is a lot of work.

JPG on the other hand just lossy compresses the color. It does not have to 'quantize' the colors. Nor does PNG.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
mr_walsh

Re: Very Slow TIFF->GIF conversion

Post by mr_walsh »

Yeah, but the source image has 2 colors - black and white - not even any greys. Isn't there a way to shortcut the process in cases like this? There's nothing to sample or dither.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Very Slow TIFF->GIF conversion

Post by anthony »

YES use +dither -map pattern:gray50

that sets a color map without dithering to the images. If the colors in the images
match the colormap than it does not have to quantize the image!

Let us know how it goes an what improvement it gives, so I can note it in IM examples.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
mr_walsh

Re: Very Slow TIFF->GIF conversion

Post by mr_walsh »

Ok, it does improve things significantly, but it's still pretty doggy...the 'assign image colors phase' is taking all the time it seems.

But I seem to have been able to switch to PNGs, which I now understand are lossless.

Code: Select all

$ time convert -monitor +dither -map pattern:gray50 test_tiff.tiff out.gif
Load image: 100%
Load image: 100%
Classify image colors: 100%
Assign image colors: 100%
Save image: 100%

real    0m1.005s
user    0m0.838s
sys     0m0.111s

-----

time convert -monitor  test_tiff.tiff out.png

$ time convert -monitor  test_tiff.tiff out.pngLoad image: 100%

real    0m0.567s
user    0m0.496s
sys     0m0.062s
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Very Slow TIFF->GIF conversion

Post by anthony »

PNG also does not use a color pallette unless PNG8 is used, or the image was already given a colormap.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply