#!/usr/bin/python # imgDetails.py - Andrew Whitehurst - v1.2 - 15/12/2004 # # A utility which scans the current directory for JPEG, GIF and PNG images, # finds out what their dimensions are and writes this in HTML to a specified file # in the same directory. # # Uses the inbuilt "sips" command in Mac OS 10.3 to gather the width and height data import sys,string,os,glob,popen2 # error checking for arguments if len(sys.argv) !=2 or sys.argv[1]=="-h" or sys.argv[1]=="-help" or sys.argv[1]=="-H": print "\n\tUSAGE : "+sys.argv[0]+" \n" print "\te.g. > ./imgDetails.py myImageInfo.html \n" print "\tThis utility will output HTML describing the width and height" print "\tparameters of all supported images in the current directory. \n" print "\tSupported file formats are JPEG, GIF, and PNG." print "\tFilenames with spaces in them are not supported,\n" print "\te.g. \"My Cool Pic.jpg\" will cause an error.\n" print "\tCurrently for Mac OS X 10.3 or greater only.\n" sys.exit(1) imgInfo=open(sys.argv[1],"w") #build the list of files dirList=glob.glob("*.jpg") dirList+=glob.glob('*.JPG') dirList+=glob.glob('*.jpeg') dirList+=glob.glob('*.JPEG') dirList+=glob.glob('*.gif') dirList+=glob.glob('*.GIF') dirList+=glob.glob('*.png') dirList+=glob.glob('*.PNG') #loop through the image list using "sips" to get the image info count=0 while count" imgInfo.write(imgData+"\n") count+=1 imgInfo.close() print "Completed output for "+str(len(dirList))+" images."