2

I generate a PDF with 288Kb size images, around 25- 30 images in that PDF and size of PDF 24MB.

How can I reduce that without loss quality of images?

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
Suresh Jagnani
  • 330
  • 2
  • 13

3 Answers3

1

I am the creator of TPPDF.

Try the following:

  • Set the quality of your PDFImage to a value less than 1.0 as it will use this for JPEG compression, defaults to 0.85
  • Play with the image options, to enable/disable compression and resizing, defaults to compress & resize

Documentation: https://github.com/techprimate/TPPDF#image

Phil Niedertscheider
  • 1,068
  • 11
  • 29
0

If the image content is stored in JPG format you cannot reduce their size without loss, they are already natively compressed as much as that standard format allows.

However many other image types may be in a PDF and may possibly be lossless encoded in a more compact format. (NOT JPG)

HOWEVER again the PDF writer should have used the optimal format anyway. CCITTFAX has very good native Compression for monochrome images.

So leaving aside images the only other bulk compressed content is FONTS (which should be imbedded) so you can reduce those by careful selection of smaller fonts.

Generally there is little gain in "PDF Optimisation" unless you already know which separate objects may benefit from a lossless redaction, or allow heavy degradation.

K J
  • 8,045
  • 3
  • 14
  • 36
-1

If you have access to linux,

  1. Install poppler and imagemagick
  2. use pdfimages from poppler to split pdf into images (png)
  3. Use mogrify to convert png to jpg
  4. Use mogrify to resize jpg
  5. Use convert to combine images into pdf

My code (shell script):

echo "Reducing $1 to $2 and saving to $3"
echo "Creating temporary directory"
mkdir temp
echo "splitting images"
pdfimages -png "$1" temp/pages
echo "converting to jpg for smaller size"
mogrify -format jpg temp/*.png
echo "resizing images to $2"
mogrify -resize $2 temp/*.jpg
echo "recombining into output pdf"
convert temp/*.jpg "$3"
echo "deleting temporary directory"
rm -r temp
echo "Done"