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?
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?
I am the creator of TPPDF.
Try the following:
quality
of your PDFImage
to a value less than 1.0
as it will use this for JPEG compression, defaults to 0.85
compress & resize
Documentation: https://github.com/techprimate/TPPDF#image
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.
If you have access to linux,
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"