liys_0 wrote:In this case, can we convert one page portion by portion to use less resources? : )
If you know the PDF is just a single page document, you could start by using ImageMagick to determine the output dimensions of the image using something like this from the command line...
Code: Select all
convert -density 200 largefile.pdf info:
That will print what the dimensions will be after converting it to a 200dpi image, and some other information.
Then when you know the size in pixels, you can read just a part of the PDF into IM's "convert" by putting the geometry of the requested portion in square brackets at the end of the file name.
For example, I checked the dimensions of my "largefile.pdf" using the command above and found it will make a 2400x2400 pixel PNG. Then if I want to get just the top left quarter of the PDF I would use a command like this...
Code: Select all
convert -density 200 largefile.pdf[1200x1200+0+0] -flatten part1A.png
With that command IM will take just a 1200x1200 piece starting at the first pixel in the upper left corner, pixel "+0+0". I can get all four quarters of the PDF into separate PNG files with a series of commands like this...
Code: Select all
convert -density 200 largefile.pdf[1200x1200+0+0] -flatten part1A.png
convert -density 200 largefile.pdf[1200x1200+1200+0] -flatten part1B.png
convert -density 200 largefile.pdf[1200x1200+0+1200] -flatten part2A.png
convert -density 200 largefile.pdf[1200x1200+1200+1200] -flatten part2B.png
To reassemble those four PNG images into a single image later I could use a command like this...
Code: Select all
convert ( part1A.png part1B.png +append ) ( part2A.png part2B.png +append ) -append largefile.png
Or maybe tile them back together with a properly constructed IM "montage" command.
To make the dis-assembly automated so it can use varying sizes of input files would require a slightly tricky BAT file with some nested "for" loops to get the image size into some variables, break it into parts by calculating those variables, and creating unique meaningful file names for all the output files. But that's a Windows programming issue, not ImageMagick.
I don't know how to run a "convert" command on a particular page of a multi-page PDF
and have it use just a segment of the page, since both those processes use square brackets at the end of the file names to specify the details. I tried using two sets of square brackets and had no success. Someone else here might know a way to make that happen. It may not be possible.