msgbartop
Illustrates and Examines some of the best tools and ideas in Computer Science
msgbarbottom

07 Jun 10 Converting Pictures and merging pdf files

I was working on a problem in graph theory sometime back and I had to work with images in png format generated by pigale. Instead of manually converting png into pdf files by printing. I decided to use shell scripts to do the same. There is a program called sam2p to convert a png file to pdf via the command line and this is how you do it.

for png in $(ls *.png)
do
	sam2p $png $png.pdf
done

So, now that I had converted every png file to a pdf file, I wanted to merge all the generated pdf files into a single pdf file so that I can peruse the pictures more easily. Thus, in order to merge the pdf files I used a program called Ghostscript which is invoked by calling gs.

rm all.pdf
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=all.pdf -dBATCH *.pdf

The output obtained after combining all pdf files is here. It is a trace of an algorithm that I was trying to develop on a sample planar graph. I tried to develop an algorithm to partition a planar graph into two outer planar graphs but I have not (yet) been able to do it.

In order to view more information regarding sam2p or gs, view their respective man pages by typing

$ man sam2p      #For sam2p man page
$ man gs            #For Ghostscript man page