How to automatically convert pdf to png with maximum dpi

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
siddartha
Posts: 1
Joined: 2019-07-26T00:36:18-07:00
Authentication code: 1152

How to automatically convert pdf to png with maximum dpi

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply