Browse Source

Поддержка сохранения выходного изображения в том-же формате, что и исходное изображение (JPEG или PNG)

master
Alexander Demidov 5 years ago
parent
commit
d8739efdc2
  1. 3
      resize.py

3
resize.py

@ -19,6 +19,7 @@ infile = args.source
outfile = args.destination
try:
im = Image.open(infile)
format = im.format
im = im.convert()
if args.width is not None or args.height is not None:
if args.width is None:
@ -55,7 +56,7 @@ try:
if args.enhance:
enhancer = ImageEnhance.Contrast(im)
im = enhancer.enhance(1.05)
im.save(outfile, "JPEG", quality=100)
im.save(outfile, format, quality=100)
except IOError as e:
print("cannot create thumbnail for '%s'" % infile)
print "I/O error({0}): {1}".format(e.errno, e.strerror)

Loading…
Cancel
Save