convert very slow for CMYK-PDFs

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
stephan2807
Posts: 3
Joined: 2015-01-19T00:52:02-07:00
Authentication code: 6789

convert very slow for CMYK-PDFs

Post by stephan2807 »

Hello,

I encounter very slow PDF-conversions for CMYK-PDFs: 15 seconds for an example CMYK-PDF vs. 0.5 seconds when I manually convert the PDF to RGB before putting it into IM.

Is there any way to speed up the conversion for CMYK-PDFs? I believe it has to do with the options IM uses for the call to ghostscript (useCIEColor). Is there a way to disable CIEColor or use a different conversion mode, even if colors would be less accurate?
I would love to use a single tool (IM) for generating thumbnails during file upload, but this delay ist often annoying.

IM is 6.6.9-7 on a i7-4770 CPU and >16GB free memory


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

Re: convert very slow for CMYK-PDFs

Post by fmw42 »

IM 6697 is rather old (over 200 versions). Perhaps an upgrade might help. Also it would useful to know what your exact command line is? Also you might post an example PDF to some place like dropbox.com and put the URL here. Then others can test with it and give you our run times.
stephan2807
Posts: 3
Joined: 2015-01-19T00:52:02-07:00
Authentication code: 6789

Re: convert very slow for CMYK-PDFs

Post by stephan2807 »

Thanks for the reply Fred.

I put 2 sample files here:
* http://148.251.8.102/RGB.pdf
* http://148.251.8.102/CMYK.pdf

My conversion times are 0.2s vs. 11s.
* convert RGB.pdf rgb.jpg (0.2s)
* convert CMYK.pdf cmyk.jpg (11s)

In the real application the conversion for CMYK is a bit more complex:
convert CMYK.pdf -profile "USWebCoatedSWOP.icc" -profile "sRGB.icm" +profile '*' -background white -flatten cmyk.jpg
The time for the test PDF is 11 seconds as well.

I will try to grab a suitable test-server for a more recent IM-install as well. (Don't want to break anything on my production server)

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

Re: convert very slow for CMYK-PDFs

Post by fmw42 »

Mac OSX Snow Leopard using only 1 thread (OpenMP disabled)

convert -version
Version: ImageMagick 6.9.0-5 Q16 x86_64 2015-01-20 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
Features: DPC Modules
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


gs --version
9.10

convert -list format
...
JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (90)
JPG* JPEG rw- Joint Photographic Experts Group JFIF format (90)


I see less than a factor 2. Perhaps it is your version of Ghostscript or libjpeg or your IM version. I think you really should try to upgrade all.

Code: Select all

time convert RGB.pdf rgb.jpg
real	0m0.575s
user	0m0.500s
sys	0m0.059s

Code: Select all

time convert CMYK.pdf cmyk.jpg
real	0m0.891s
user	0m0.798s
sys	0m0.078s

Code: Select all

time convert -colorspace RGB CMYK.pdf cmyk.jpg
real	0m1.002s
user	0m0.905s
sys	0m0.066s
stephan2807
Posts: 3
Joined: 2015-01-19T00:52:02-07:00
Authentication code: 6789

Re: convert very slow for CMYK-PDFs

Post by stephan2807 »

Many thanks. Looks like it is the ghostscript version.
Did a test on Windows with pure gs 9.05, 9.10 and 9.15:
- 9.05 is extremely slow as I observed on Linux
- 9.10 and 9.15 are equaly fast like in your test.
The results are almost the same accross all the 3 gs-versions.

gs-call was:
gswin32c -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=jpeg -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dNumRenderingThreads=4 -r72x72 -dUseCIEColor -sOutputFile=cmyk.jpg -fcmyk.pdf

Stephan
Post Reply