minimal erweitert

This commit is contained in:
age 2012-07-19 22:08:01 +00:00
parent 38027320ff
commit 5e7433ab56
1 changed files with 24 additions and 1 deletions

View File

@ -17,6 +17,7 @@ Options:
--html Output HTML to stdout
--resize x y Resize specified images to x,y
--resize-ratio x Resize specified images with correct aspect ratio
--resize-ratio-y y Resize specified images with correct aspect ratio
--rotate x Rotate the image counter clockwise for x degrees
--size Display the image sizes
--thumbnail x y Make thumbnails of specified images, ignoring existing
@ -88,6 +89,8 @@ def resize_images (args):
im2 = im.resize((x,y))
print >>sys.stderr, ('%s: was %i,%i; resizing to %i,%i'
% (filename, w,h, x,y) )
root, ext = os.path.splitext(filename)
filename = ('%s_%s%s%s%s%s') % (root, 'x', w, 'y', h , ext)
im2.save(filename)
def resize_images_aspectratio (args):
@ -100,6 +103,23 @@ def resize_images_aspectratio (args):
im2 = im.resize((x,y))
print >>sys.stderr, ('%s: was %i,%i; resizing to %i,%i'
% (filename, w,h, x,y) )
root, ext = os.path.splitext(filename)
filename = ('%s_%s%s%s') % (root, 'x', x , ext)
im2.save(filename)
def resize_images_aspectratio_y (args):
y = int(args[0])
args = args[1:] ; args.sort()
for filename in args:
im = Image.open(filename)
w,h = im.size
x = y*w/h
im2 = im.resize((x,y))
print >>sys.stderr, ('%s: was %i,%i; resizing to %i,%i'
% (filename, w,h, x,y) )
root, ext = os.path.splitext(filename)
filename = ('%s_%s%s%s') % (root, 'y', y , ext)
im2.save(filename)
@ -111,6 +131,7 @@ def main ():
'html',
'resize',
'resize-ratio',
'resize-ratio-y',
'size',
'thumbnail',
'rotate'])
@ -141,6 +162,8 @@ def main ():
resize_images(args)
elif opt == '--resize-ratio':
resize_images_aspectratio(args)
elif opt == '--resize-ratio-y':
resize_images_aspectratio_y(args)
elif opt == '--rotate':
rotate_images(args)
elif opt == '--size':