This is the first post for my blog. I will update this later…
And I am now. This blog space will be used for sharing photos, code snippets, and whatever else I feel would be useful to share. For a start, here’s a useful little python script for resizing a directory of images:
def resizeAll(files,maxDim): from wand import image if isinstance(files,str): files=[files] for f in files: print "Resizing " + f im=image.Image(filename=f) newWidth=int(maxDim) newHeight=int(maxDim/aspect) im.resize(width=newWidth,height=newHeight) saveName=f[:-4]+'_resized'+f[-4::] im.save(filename=saveName) im.close()
The script requires a list of files and the size of the largest dimension to resize the images to. It preserves aspect ratio and saves the resized images to the same directory as the original image was in. Resized images have the same name plus a “_resized” added to the name. This script of course requires the ImageMagick library and the wand python library.