Image Conversion

Image Conversion & PDF shrinkage

Problem : I need to take a bunch of mixed images of jpg and png origin and convert them to a PDF file.
Solution : convert all to one file type, then convert them all to a single PDF and THEN shrink the PDF to a normal size….
tools needed : imagemagick, ghostscript, bash/zsh and a bunch of images

procedure :

I have all these images sitting in a directory :

img011.png img013.jpg img015.png img017.png img019.png img021.png img023.png img025.png img3.jpg img5.png img7.png img010.png img012.png img014.png img016.jpg img018.png img020.png img022.png img024.png img09.png img1.png img2.png img4.png img6.png img8.png

Lets convert them all to jpg first :

mogrify -format jpg *.png

now we have all jpg images (you can do it the opposite way also, just replace jpg with png in above and vice versa). So lets convert them all to a PDF file :

convert *.jpg img1.pdf

but its HUGE! AMIGAWD! etc… so we need to slim it down a little, get it some slimfasts etc…. so here we go! you need ghostscript for this next step ( sudo apt-get install ghostscript | yum install ghostscript )

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=OUTPUT.pdf INPUT.pdf

AMIGAWD*2 look at the size difference!

% ll img*.pdf   
-rw-rw-r-- 1 kingpin kingpin 155679662 2012-03-12 14:04 INPUT.pdf
-rw-rw-r-- 1 kingpin kingpin   1689376 2012-03-12 14:08 OUTPUT.pdf

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *