I would like to use ghostscript to convert the pdf source into series of jpeg images. Everything works fine except:
- The format specifiers (%d) for .jpeg output file names are not working on
Windows (I am using Windows 7 64bit), so I need to call gswin64c.exe as for every single page. - The exported .jpeg files have white stripes around the page, while .pdf
does not have anything there – can I get somehow rid of them?
My command line:
gswin64c.exe \
-dSAFER -dBATCH -dNOPAUSE \
-sDEVICE=jpeg \
-r350 \
-dJPEGQ=100 \
-dFirstPage=1 -dLastPage=1 \
-sOutputFile=magazine-1.jpg \
magazine.pdf
On Windows, you have to double the
%character for the format specifier to get the page number increment:gswin64c.exe \ -o magazine-page_%%04d.jpg \ -sDEVICE=jpeg \ -r350 \ -dJPEGQ=100 \ magazine.pdfWithout seeing your PDF, I cannot tell for sure where your white strips come from.
So, just theorizing: Usually, what appears in PDF pages (viewed in a PDF reader or printed on paper) as a white background in reality is a transparent background. (You can make transparent areas visible in Acrobat Reader: go to Preferences… -> Page display and activate the checkbox Show transparency grid.
JPEG does not know about transparency and converts all fully transparent areas to white.
You could trim the white areas off with the help of ImageMagick. Or, if you know the exact widths of each of the strips (and the PDF page dimensions), you could tell Ghostscript via additional commandline parameters to trim away these…
You could also convert to PNG, which supports transparency:
gswin64c.exe \ -o magazine-page_%%04d.png \ -sDEVICE=pngalpha \ -r350 \ magazine.pdfNote, that there will still be stripes around the page image — however they will be transparent instead of white.