I have a document with a few large (EPS) bitmaps. I want to create a high-quality PDF document out of this with ps2pdf (or some other tool if that would be easier).
My problem is this: using -dColorImageFilter=/FlateEncode gives me high-quality images, but too large according to my annoying printshop. Using /DCTEncode instead gives me a smaller file, but with too much compression of the images.
How can I control the compression ratio? I have seen that there is an option QFactor that controls this, but setting -dQFactor=0.15 doesn't change anything.
(As a side note, I also tried using pdflatex to generate a PDF directly, but then the high-quality JPG images I have get recompressed to worse quality, for a reason I also don't understand.)
Conversion Tools ⇒ How to control JPG compression ratio with ps2pdf
-
- Posts: 26
- Joined: Mon Mar 09, 2009 3:19 pm
How to control JPG compression ratio with ps2pdf
Recently, I asked the very same question. It seems that this just can't be done with GhostScript at all (ps2pdf is just a wrapper around gs).
You can try direct conversion from jpg to pdf with convert from image magick or sam2p. Both should preserve the original image quality. With convert you can also control the scaling of the final image using -density option. Then use those converted images with pdflatex and see if it helps.
Cheers,
Tomek
That sounds odd. AFAIK, pdflatex shouldn't do any reencoding of jpeg images. It just includes them verbatim as they are. What viewer do you use?jazzgossen wrote:As a side note, I also tried using pdflatex to generate a PDF directly, but then the high-quality JPG images I have get recompressed to worse quality, for a reason I also don't understand.
You can try direct conversion from jpg to pdf with convert from image magick or sam2p. Both should preserve the original image quality. With convert you can also control the scaling of the final image using -density option. Then use those converted images with pdflatex and see if it helps.
Cheers,
Tomek
-
- Posts: 26
- Joined: Mon Mar 09, 2009 3:19 pm
Re: How to control JPG compression ratio with ps2pdf
OK. Good to know that it isn't possible with ps2pdf. I'll try to use pdflatex instead, then.
The quality issue with pdflatex was my fault. I had some pdf versions of some images that pdflatex chose instead of the good jpg images I thought it would choose.
sam2p looks interesting too. Thanks for the notice.
The quality issue with pdflatex was my fault. I had some pdf versions of some images that pdflatex chose instead of the good jpg images I thought it would choose.
sam2p looks interesting too. Thanks for the notice.
How to control JPG compression ratio with ps2pdf
Yes you can control the JPG compression ratio when using ps2pdf by adjusting the -dJPEGQ option. you can set it to a value between 0 and 100, where 0 is the lowest quality (highest compression) and 100 is the highest quality lowest compression.
You can experiment with different values to find the right balance between file size and image quality.
see this tool jpeg compressor how they compressed it in balanced.
Code: Select all
ps2pdf -dJPEGQ=75 input.ps output.pdf
see this tool jpeg compressor how they compressed it in balanced.