Converting PDF to JPG: problem w/images inside the PDF

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
paol0
Posts: 1
Joined: 2012-10-25T01:24:46-07:00
Authentication code: 67789

Converting PDF to JPG: problem w/images inside the PDF

Post by paol0 »

Hello,

I'm converting PDFs to sequences of JPGs.

Images inside the PDF are not rendered well. I think there is some problem in scaling, and artifacts appears.

Below is an explaining image with two portiong of a JPG obtained from PDF.

On the left side the result is from Photoshop. On the right from ImageMagick (look at diagonal lines)

Image

The issued command that generated the PDF with ImageMagick was

convert -colorspace sRGB -quality 92 -density 75 -strip /Users/paolo/Desktop/test/test.pdf /Users/paolo/Desktop/test/test.jpg

(In case it may be usefull to know: the image inside the PDF, is CMYK, 90 dpi, with Jpeg compression, so ImageMagick is actually performing a downsample).

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

Re: Converting PDF to JPG: problem w/images inside the PDF

Post by fmw42 »

try increasing the density
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Converting PDF to JPG: problem w/images inside the PDF

Post by magick »

To increase the quality of the PDF rendering, supersample:
  • convert -colorspace sRGB -quality 92 -density 300 -strip /Users/paolo/Desktop/test/test.pdf -resize 25% /Users/paolo/Desktop/test/test.jpg
rubenvb
Posts: 2
Joined: 2014-07-25T02:37:02-07:00
Authentication code: 6789

Re: Converting PDF to JPG: problem w/images inside the PDF

Post by rubenvb »

I have the same issue converting a pdf file to a png file with the command:

Code: Select all

convert -density=1800 testgradient.pdf testgradient.png
The resulting PNG has some mis-coloured pixels, which are unwanted, and the PDF only contains vector graphics.
The DF file is available here:
https://dl.dropboxusercontent.com/u/587 ... adient.pdf

and was generated from following LaTeX/TikZ code with pdflatex:

Code: Select all

\documentclass{standalone}
\pagestyle{empty}
 
\usepackage{tikz}
\usetikzlibrary{shadings}

\begin{document}
\begin{tikzpicture}
\coordinate (center) at (0,0);

\shade[shading=color wheel] (center) circle (1);
\end{tikzpicture}
\end{document}
using an even higher depth and scaling that back gets rid of the artifacts though that shouldn't be necessary, also, it uses a lot more memory and results in a relatively much larger file:

Code: Select all

convert -density 7200 -resize 25% testgradient.pdf testgradient.png
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Converting PDF to JPG: problem w/images inside the PDF

Post by magick »

We get expected results. We're using ImageMagick 6.8.9-5, the current release, and Ghostscript 9.14.
rubenvb
Posts: 2
Joined: 2014-07-25T02:37:02-07:00
Authentication code: 6789

Re: Converting PDF to JPG: problem w/images inside the PDF

Post by rubenvb »

You are right, I can't reproduce this anymore. Sorry for the noise.
Post Reply