I am trying to convert a PDF to JPEG by rendering with at 2x the intended output density, downsampling to get antialiased lines, and finally assigning the output JPG proper density (ppi) metadata so that its physical size in inches is the same as the original PDF (even if ppi is different).
Taking into accound Imagemagick considers all PDFs to be 72 ppi, consider this example:
- The input PDF is 10x10 inches, i.e. 720x720px at 72 ppi
- The output JPG should be 1440x1440px at 144ppi
Code: Select all
convert -density 288x -geometry 1440x input.pdf -density 144x output.jpg
Code: Select all
144 = output size in px / (input width in px / original dpi) = 1440 / (720 / 72)
Code: Select all
convert -density "%[fx:round(2*(1440/(w/resolution.x)))"x -geometry 1440x input.pdf -density "%[fx:round((1440/(w/resolution.x)))"x output.jpg