* bilder mit korrektem seitenverhaeltnis aendern

This commit is contained in:
age 2007-02-22 00:15:08 +00:00
parent d7d7b6addd
commit 80dcd225cb

View file

@ -89,6 +89,19 @@ def resize_images (args):
% (filename, w,h, x,y) )
im2.save(filename)
def resize_images_aspectratio (args):
x = int(args[0])
args = args[1:] ; args.sort()
for filename in args:
im = Image.open(filename)
w,h = im.size
y = x*h/w
im2 = im.resize((x,y))
print >>sys.stderr, ('%s: was %i,%i; resizing to %i,%i'
% (filename, w,h, x,y) )
im2.save(filename)
def main ():
opts, args = getopt.getopt(sys.argv[1:],
@ -96,6 +109,7 @@ def main ():
['help',
'html',
'resize',
'resize-ratio',
'size',
'thumbnail',
'rotate'])
@ -111,8 +125,7 @@ def main ():
# Ensure that exactly one option is supplied
if len(opts) == 0:
print >> sys.stderr, ("%s: must specify one of --size, --help"
"\n --html, --resize, --thumbnail --rotate" %
sys.argv[0] )
"\n --html, --resize, --resize-ratio, --thumbnail --rotate" % sys.argv[0] )
sys.exit(0)
elif len(opts) > 1:
print >> sys.stderr, ("%s: cannot specify multiple options" %
@ -125,6 +138,8 @@ def main ():
output_html(args)
elif opt == '--resize':
resize_images(args)
elif opt == '--resize-ratio':
resize_images_aspectratio(args)
elif opt == '--rotate':
rotate_images(args)
elif opt == '--size':