get initial resolution of PDF to generate jpg

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
blanca

get initial resolution of PDF to generate jpg

Post by blanca »

I am currently using Jmagick to convert a pdf to several jpg. Why I know the initial resolution of pages PDF? My goal is to generate jpg with the original resolution. For example, imagine that the pdf file was generated with a jpg file of 300 dpi. Then, when I do info.setDensity,

ImageInfo info = new ImageInfo(pdf.getAbsolutePath());
info.setDensity("200");

I would like put the next:

info.setDensity("dpi of pdf file")

how do it???
Thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: get initial resolution of PDF to generate jpg

Post by anthony »

A PDF does not have a 'fixed' resolution. Or at least it is not supposed to. This is a property of VECTOR image type formats.
http://imagemagick.org/Usage/formats/#vector

However if a PDF has a raster image in it. That image may have an ideal resolution, for which it was generated. The image however should be automatically scaled appropriatally for the resoution the PDF is being 'printed' to or 'displayed' at.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
blanca

Re: get initial resolution of PDF to generate jpg

Post by blanca »

"The image however should be automatically scaled appropriatally for the resoution the PDF is being 'printed' to or 'displayed' at." But, How know the PDF resolution? It's essential to scale the images.
Thanks.
blanca

Re: get initial resolution of PDF to generate jpg

Post by blanca »

Really what I mean is: how can I know the ideal resolution for which was generated the images from PDF file?
Thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: get initial resolution of PDF to generate jpg

Post by anthony »

That is a million dollar question! And basically I don't think you can know!

I have a similar problem for extracting such pictures and images from PDF and postscript files, directly at the resolution it was saved in that file. That is the image that is present without any resizing or scaling. I have yet to find a solution.

The problem is both PDF and PS are languages, not just data files. They have programs that can obfuscate, modify and rescale that data during the 'printing' process. Unless you are dealing with a well known 'version' or format style of PDF or Postscript, you can not get the image data without it being 'drawn'. The language is not designed for that. Period.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply