Поддержка сохранения выходного изображения в том-же формате, что и исходное изображение (JPEG или PNG)
This commit is contained in:
@ -19,6 +19,7 @@ infile = args.source
|
|||||||
outfile = args.destination
|
outfile = args.destination
|
||||||
try:
|
try:
|
||||||
im = Image.open(infile)
|
im = Image.open(infile)
|
||||||
|
format = im.format
|
||||||
im = im.convert()
|
im = im.convert()
|
||||||
if args.width is not None or args.height is not None:
|
if args.width is not None or args.height is not None:
|
||||||
if args.width is None:
|
if args.width is None:
|
||||||
@ -55,7 +56,7 @@ try:
|
|||||||
if args.enhance:
|
if args.enhance:
|
||||||
enhancer = ImageEnhance.Contrast(im)
|
enhancer = ImageEnhance.Contrast(im)
|
||||||
im = enhancer.enhance(1.05)
|
im = enhancer.enhance(1.05)
|
||||||
im.save(outfile, "JPEG", quality=100)
|
im.save(outfile, format, quality=100)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print("cannot create thumbnail for '%s'" % infile)
|
print("cannot create thumbnail for '%s'" % infile)
|
||||||
print "I/O error({0}): {1}".format(e.errno, e.strerror)
|
print "I/O error({0}): {1}".format(e.errno, e.strerror)
|
||||||
|
Reference in New Issue
Block a user