Creating JPG thumbnails from PDF causes problems with the new version of ImageMagick

I use Imagemagick to create thumbnail images of PDF files with this command:

convert 'input.pdf[0]' -resize "100x140>" -colorspace 'rgb' 'output.jpg' 2>/dev/null 

Some of the PDF files are in the CMYK color space, so the specification of the expected color space is rgb. This worked fine until I upgraded to the latest versions of Imagemagick (6.6.7-1) and ghostscript (9.01_0), now it looks like the conversion to rgb no longer works, here is an example output:

failed cymk-rgb conversion

(The background should be white, not black) It seems that the problem arises from the -resize option, because if I remove it, the result will be correct.

To get the expected result, I make two passes, the first to convert to rgb, and the second to resize the image, but it's not very elegant. Is there a better solution?

+4
source share
2 answers

I solved this problem by passing the extra -flatten option. Now my thumbnails are displayed correctly.

+3
source

What if you change the settings? This can save you from running two different teams. Because these two teams:

 convert 'in.pdf[0]' -resize "100x140>" -colorspace 'rgb' 'out.jpg' convert 'in.pdf[0]' -colorspace 'rgb' -resize "100x140>" 'out.jpg' 

will call (latest versions) ImageMagick to process files differently; each time it follows the order specified on the command line (this is not true for older versions).

0
source

Source: https://habr.com/ru/post/1340160/


All Articles