minimal erweitert
This commit is contained in:
parent
38027320ff
commit
5e7433ab56
1 changed files with 24 additions and 1 deletions
25
gallery.py
25
gallery.py
|
@ -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,9 +131,10 @@ def main ():
|
|||
'html',
|
||||
'resize',
|
||||
'resize-ratio',
|
||||
'resize-ratio-y',
|
||||
'size',
|
||||
'thumbnail',
|
||||
'rotate'])
|
||||
'rotate'])
|
||||
|
||||
# Remove the unused option arguments
|
||||
opts = [opt for opt,arg in opts]
|
||||
|
@ -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':
|
||||
|
|
Loading…
Reference in a new issue