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
|
--html Output HTML to stdout
|
||||||
--resize x y Resize specified images to x,y
|
--resize x y Resize specified images to x,y
|
||||||
--resize-ratio x Resize specified images with correct aspect ratio
|
--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
|
--rotate x Rotate the image counter clockwise for x degrees
|
||||||
--size Display the image sizes
|
--size Display the image sizes
|
||||||
--thumbnail x y Make thumbnails of specified images, ignoring existing
|
--thumbnail x y Make thumbnails of specified images, ignoring existing
|
||||||
|
@ -88,6 +89,8 @@ def resize_images (args):
|
||||||
im2 = im.resize((x,y))
|
im2 = im.resize((x,y))
|
||||||
print >>sys.stderr, ('%s: was %i,%i; resizing to %i,%i'
|
print >>sys.stderr, ('%s: was %i,%i; resizing to %i,%i'
|
||||||
% (filename, w,h, x,y) )
|
% (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)
|
im2.save(filename)
|
||||||
|
|
||||||
def resize_images_aspectratio (args):
|
def resize_images_aspectratio (args):
|
||||||
|
@ -100,6 +103,23 @@ def resize_images_aspectratio (args):
|
||||||
im2 = im.resize((x,y))
|
im2 = im.resize((x,y))
|
||||||
print >>sys.stderr, ('%s: was %i,%i; resizing to %i,%i'
|
print >>sys.stderr, ('%s: was %i,%i; resizing to %i,%i'
|
||||||
% (filename, w,h, x,y) )
|
% (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)
|
im2.save(filename)
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,9 +131,10 @@ def main ():
|
||||||
'html',
|
'html',
|
||||||
'resize',
|
'resize',
|
||||||
'resize-ratio',
|
'resize-ratio',
|
||||||
|
'resize-ratio-y',
|
||||||
'size',
|
'size',
|
||||||
'thumbnail',
|
'thumbnail',
|
||||||
'rotate'])
|
'rotate'])
|
||||||
|
|
||||||
# Remove the unused option arguments
|
# Remove the unused option arguments
|
||||||
opts = [opt for opt,arg in opts]
|
opts = [opt for opt,arg in opts]
|
||||||
|
@ -141,6 +162,8 @@ def main ():
|
||||||
resize_images(args)
|
resize_images(args)
|
||||||
elif opt == '--resize-ratio':
|
elif opt == '--resize-ratio':
|
||||||
resize_images_aspectratio(args)
|
resize_images_aspectratio(args)
|
||||||
|
elif opt == '--resize-ratio-y':
|
||||||
|
resize_images_aspectratio_y(args)
|
||||||
elif opt == '--rotate':
|
elif opt == '--rotate':
|
||||||
rotate_images(args)
|
rotate_images(args)
|
||||||
elif opt == '--size':
|
elif opt == '--size':
|
||||||
|
|
Loading…
Add table
Reference in a new issue