Creating JPG thumbnails from PDF causes problems with new version of ImageMagick
I'm using Imagemagick to create thumbnails images of pdf files with this command:
convert 'input.pdf[0]' -resize "100x140>" -colorspace 'rgb' 'output.jpg' 2>/dev/null
Some of the PDFs are in CMYK color space, henc开发者_如何学Goe the specification of the expected -colorspace as rgb. This was working fine until I updated to the latest versions of Imagemagick(6.6.7-1) and ghostscript(9.01_0), now it looks like the conversion to rgb isn't working any longer, here is an example output:
(The background should be white, not black) It seems though that the problem comes from the -resize option because if I remove it the output is correct.
To get the expected output I now do two passes, the first to convert to rgb and the second to resize the image, but that's not very elegant. Is there a better solution?
I solved this problem by passing the extra -flatten
option. Now my thumbnails are render correctly.
What if you swap options? This may save you from running the 2 different commands. Because these two commands:
convert 'in.pdf[0]' -resize "100x140>" -colorspace 'rgb' 'out.jpg'
convert 'in.pdf[0]' -colorspace 'rgb' -resize "100x140>" 'out.jpg'
will cause (recent versions of) ImageMagick to process the files in a different way; it each times follows the order given on the commandline (this is not true for older versions).
精彩评论