2

Is it possible to turn off or lower the compression of images inside a PDF with Ghostscript when I convert to jpg?

I currently use the following:

gs \
 -dNOPAUSE \
 -q \
 -dBATCH \
 -dSAFER \
 -sDEVICE=jpeg \
 -dUseCIEColor \
 -dJPEGQ=95 \
 -r150 \
 -dTextAlphaBits=4 \
 -dGraphicsAlphaBits=4 \
 -dMaxStripSize=8192 \
 -sOutputFile=/test_dir/test-%d.jpg \
  "/test-dir/test.pdf"
2

This commandline parameter

-dJPEGQ=95

deteriorates the JPEG Quality already! To keep the original JPEG quality of images embedded in the original PDF, and to minimize quality deterioration for other parts of your PDF page objects, use

-dJPEGQ=100

Keep in mind that JPEG is a lossy image format anyway. If your PDF pages did come with text sections, you will always lose quality, because JPEG isn't a good format to convert to if you have many small areas with sharply contrasting filled areas (such as black characters on white background are). (PNG is a better format for this.)

The next parameter you can employ to increase your output quality is for resolution:

-r150

Try this instead:

-r300

or even

-r600

(File sizes will roughly quadruple each time... but that's the price of increased quality.)

You may be better off by converting to TIFF or PNG... unless your need is for JPEG explicitly for some other reason.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.