From 9c7a73fb817195d1247d52b40e250da720c9958a Mon Sep 17 00:00:00 2001 From: Brian Mattern Date: Mon, 26 Mar 2012 17:19:27 -0700 Subject: [PATCH] no need to specify image type to save as --- hyde/ext/plugins/images.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hyde/ext/plugins/images.py b/hyde/ext/plugins/images.py index 69b17a2..9a6c8d9 100644 --- a/hyde/ext/plugins/images.py +++ b/hyde/ext/plugins/images.py @@ -253,6 +253,7 @@ class ImageThumbnailsPlugin(Plugin): im = Image.open(resource.path) if im.mode != 'RGBA': im = im.convert('RGBA') + format = im.format if preserve_orientation and im.size[1] > im.size[0]: width, height = height, width @@ -272,10 +273,11 @@ class ImageThumbnailsPlugin(Plugin): im = im.crop((shiftx, shifty, width + shiftx, height + shifty)) im.load() - if resource.name.endswith(".jpg"): - im.save(target.path, "JPEG", optimize=True, quality=75) - else: - im.save(target.path, "PNG", optimize=True) + options = dict(optimize=True) + if format == "JPEG": + options['quality'] = 75 + + im.save(target.path, **options) def begin_site(self): """