Page 1 of 1

How to automatically convert pdf to png with maximum dpi

Posted: 2019-07-26T00:54:00-07:00
by siddartha
Dear ImageMagick community members,

I would like to know how to automatically convert pdf to png image with maximum dpi the system memory can support.
For example the following command in Ubuntu converts pdf file to png image with the specified dpi value.

convert -density <dpi_value> <file.pdf> <file.png>

But the above is not what I am looking for. For example, my application needs good quality png image with maximum resolution. There is no upper limit on maximum resolution. More the resolution, better will be my application accuracy.

So I would like ask the community members is there any way, either C/C++ program or command line option, such that, input is the pdf file and output is png image with maximum resolution/dpi ImageMagick can support. I also assume there is a cache memory used in the process and it has upper limit.

My application consists of many pdf files and they are different with respect to file size, font etc., If for example a dpi value of 1000 is the maximum value the ImageMagick can support for one pdf file, but for other pdf fie, it may support till 1400 dpi value. hence I would like to automate the process.

Thanks in advance.

Regards
Siddartha

Re: How to automatically convert pdf to png with maximum dpi

Posted: 2019-07-26T06:06:57-07:00
by snibgo
siddartha wrote:I also assume there is a cache memory used in the process and it has upper limit.
It uses memory. I don't think IM imposes an upper limit. Ghostscript might. It may also depend on your platform (Windows, whatever), and on what other processes are using memory.

I suppose the memory used is proportional to the density squared, and the number of pixels at any standard density. You could check this for your computer. So you could rasterize at one density to find the number of pixels, and do a calculation to find the highest density that doesn't break your memory budget.