XYK

Batch Resizing with IRFanView and Python

January 6th, 2013

Sandbox

Batch resizing with IRfanview

This is a script I use to quickly compress and resize my photos for the web. Edit the parameters, copy and paste it to the image directory, and run it. The script will create a ‘/resized’ folder for all the processed photos.

import os

IVIEW32_PATH = 'C:\Program Files (x86)\IrfanView\i_view32.exe'
SOURCE_FILETYPE = 'jpg'
TARGET_FILETYPE = 'jpg'
TARGET_WIDTH = 1024
TARGET_HEIGHT = 768

command = '"%s" '%IVIEW32_PATH + os.getcwd() + r"\*.%s /resize=(%d,%d) /aspectratio /resample /convert="%(SOURCE_FILETYPE,TARGET_WIDTH,TARGET_HEIGHT) + os.getcwd() + r"\resized\*.%s"%TARGET_FILETYPE
os.system(command)

Requires IrfanView and python.