<s> import glob <EOL> import os . path <EOL> from dirwalk import includingWalk <EOL> from os import system <EOL> from subprocess import Popen , PIPE , STDOUT <EOL> from compmodtimes import compmodtimes <EOL> from PIL import Image <EOL> def resize_image ( fname , max_width = <NUM_LIT> ) : <EOL> im = Image . open ( fname ) <EOL> width , height = tuple ( im . getbbox ( ) [ <NUM_LIT:2> : ] ) <EOL> print '<STR_LIT>' , height , '<STR_LIT>' , width <EOL> if width > max_width : <EOL> wrat = max_width / float ( width ) <EOL> new_w = int ( width * wrat ) <EOL> new_h = int ( height * wrat ) <EOL> newim = im . transform ( ( new_w , new_h ) , Image . EXTENT , <EOL> im . getbbox ( ) , Image . BICUBIC ) <EOL> newim . save ( fname ) <EOL> for diafile in includingWalk ( "<STR_LIT:..>" , [ "<STR_LIT>" ] ) : <EOL> pth = os . path . split ( diafile ) <EOL> dest = pth [ <NUM_LIT:1> ] . split ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] <EOL> retcode = compmodtimes ( diafile , '<STR_LIT>' + dest + '<STR_LIT>' ) <EOL> if retcode == - <NUM_LIT:1> or retcode == <NUM_LIT:0> : <EOL> print '<STR_LIT>' + dest + '<STR_LIT>' <EOL> else : <EOL> cmd = '<STR_LIT>' + dest + '<STR_LIT>' + diafile <EOL> system ( cmd ) <EOL> resize_image ( os . path . abspath ( os . path . join ( '<STR_LIT>' , dest + '<STR_LIT>' ) ) ) </s>
