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
Linux shell

Create Thumbnails from a bunch of images

Linux Code snippet. Ever wated to batch create thumbnails? “musclecarr” posted this bash script to create thumbnails of all images of a specific type. It uses imagemagick and specifically the convert command. minor modifications done to it and comments added for easy understanding, here it is :

# take argument or use current dir
# create dir thumbs if doesnt exist
[ -d "$DIR/thumbs" ] || mkdir "$DIR/thumbs"
# error out if cant enter dir for some reason (permissions?)
cd "$DIR" || { echo >&2 "error: couldn't enter directory: $DIR"; exit 1;}
# For every file with extension XXX (jpg in this case)
for i in ./*.jpg; do
# Resize image to 100x100
convert "$i" -resize 100x100 "$DIR/thumbs/$i"
# profit? nah.