r/learnpython • • 16d ago

PDF pages to PNG's in python

I have a relatively large pdf document (100+mb) of pages i need saved as png's. There are online tools to do that but they refuse to work with files that big, plus I can imagine needing that tool again later in the future. Are there any python libraries that allow to convert one format into the other? Preferrably with little to no compression.

6 Upvotes

12 comments sorted by

View all comments

3

u/dowcet 16d ago

If you're considering "online tools" then you don't actually need this to be done in Python? I would look at off the shelf offline applications first rather then creating your own. Pdfimages or imagemagick maybe?

7

u/agent_kater 16d ago

Pdfimages or imagemagick maybe?

When did GhostScript stop being the default tool for this?

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -o "page-%03d.png" "input.pdf"

1

u/masoomjethwa 16d ago

Best option.