convert is so slow!

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
eslavko
Posts: 3
Joined: 2011-09-04T10:46:27-07:00
Authentication code: 8675308

convert is so slow!

Post by eslavko »

Hello...

with commandline on WinXP I got very slow response.
The test.tif is rather big. it's 4437x6580 and action takes 25 second to finish.

The commandline....
convert test.tif -chop 3x4! -monitor -colorspace gray -white-threshold 1 -depth 1 out.tif


And what I wan't to do.
The tiff is realy output from scantailor. And it has black text and images in some place. The images can be grayscale or color.
With that commandline I want to do folowing.
crop size to be divisible with some numbers (ie to have integers at 600dpi and 100dpi from same image)
then I wan't to get just bacground and black color (text) in output tiff with 1bpp.
The result is what I want.

similar command takes 9 seconds
convert testcolor.tif -chop 3x4! -monitor -fill white -opaque black -depth 8 -resample 100 x03.ppm
and should do just oposite. It's make black transparent(white) and save with lowered resoluiton.

intention is to make good djvu. And need separate file for foreground and background.

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

Re: convert is so slow!

Post by fmw42 »

The test.tif is rather big. it's 4437x6580 and action takes 25 second to finish.

The commandline....
convert test.tif -chop 3x4! -monitor -colorspace gray -white-threshold 1 -depth 1 out.tif
try saving to png or some other format to test if it is the tiff writer being slow or just the size of your image and perhaps not enough memory and thrashing to disk.
eslavko
Posts: 3
Joined: 2011-09-04T10:46:27-07:00
Authentication code: 8675308

Re: convert is so slow!

Post by eslavko »

Hello.


I tried few other file format's.
The result is wery strange for me. The output format has wery little impact on time. The difference is few seconds. The tif seems to be fastest and ppm is slowest. (seems to be proportional with output file size).
But what surprise me is that that input file format has enormous impact. Same input file just converted to ppm take over minute and half!

I test to resize image by half in x&y. Si image is 1/4 of size. the processing time is near exact 1/4 time of original. As that file is short I can guarante that is not swaped to disk. Either in big file the HDD LED doesn't blink when conversion is in progress. So I assume it's run from ram. (I have just 1GB of ram but system manager show's that image processing took aprox 200k of memory)

the switch -depth 1 is that one that cause slow work. Without that image processing is fast (6 seconds) but of course image is wrong.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert is so slow!

Post by fmw42 »

If you are thresholding, you likely don't need -depth 1 as thresholding causes a binary result anyway. But if it does not, just put -type bilevel rather than -depth 1.
eslavko
Posts: 3
Joined: 2011-09-04T10:46:27-07:00
Authentication code: 8675308

Re: convert is so slow!

Post by eslavko »

Hello...

I need 1bpp output file for next step.

Thanks for help.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: convert is so slow!

Post by magick »

If there is not enough memory available, image pixels are cached to disk rather than memory which can be quite slow. You can reduce memory requirements by downloading the Q8 version of ImageMagick. The default is Q16 (16-bits per pixel). We tried your command with ImageMagick 6.7.2-2 and it completed in less than 4 seconds.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert is so slow!

Post by fmw42 »

GM is probably using a much simpler resampling/filter method than IM. Try using -scale rather than -resize (or -filter point -resize ... or -filter triangle -resize ...)

Did you try removing the -depth 1 or change it to -type bilevel (with -threshold you should not need either).
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: convert is so slow!

Post by anthony »

GM was also a fork before the filter re-programming I undertook. As such some filters (such as BlackMan) are simply wrong. The reason for the re-programming was so that 'cylindrical filters' were available using image distortions, so GM does not have that operation either. So no Distort Resize variation!

http://www.imagemagick.org/Usage/resize/#distort_resize
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply