Run a Shell Command in a Makefile

I had a directory of BMP image files that I wanted to convert to EPS (Encapsulated PostScript). Since I was planning on adding files to the directory, I did not want to hard code the names of the files into the makefile that would do the conversion. Therefore, the trick was to run a shell command inside of the makefile. The first line lists all of the BMP files and assigns it to “BMP_FILES”. The next line replaces the “bmp” extension with “eps”. The complete makefile is below.

BMP_FILES = $(shell ls *.bmp)
EPS_FILES = ${BMP_FILES:%.bmp=%.eps}

all: ${EPS_FILES}

%.eps : %.bmp
	convert $*.bmp $*.eps

All that is left is to type “make” in the directory, and all of the BMP files will be converted to EPS.

PDF to PNG Conversion on Mac OS X

I had a several page scanned document stored in PDF format that I needed to convert to PNG so I could upload it to a PayPal account to resolve a limited access problem. I found several solutions for Linux that produced inadequate image files. When I switched to my Mac OS X laptop, I opened the PDF in Preview. I selected “Save As…” from the File menu, selected “PNG” from the drop down menu and set the resolution to 300 pixels per inch. I hit the Save button, and the newly created PNG opened up. The quality was adequate, and the problem was solved.