My first python program
I’m learning python, so I figured I’d post my first little program. This takes in command-line input arguments and converts the .pdf files to .png images.
#!/usr/bin/env python # pdf2png converts pdf files to .png files import sys, os inputfilenames = sys.argv[1:] for inputfilename in inputfilenames: (fileBaseName, fileExtension)=os.path.splitext(inputfilename) print 'filename=' + fileBaseName newfilename=fileBaseName + '%d.png' newfilenameSmall=fileBaseName + '%d_s.png' cmd="convert -density 300 '" + inputfilename + "' -scale 720 -colors 256 -depth 8 -quality 90 '" + newfilename + "'" os.system(cmd)