Browse Source

no need to specify image type to save as

main
Brian Mattern 12 years ago
committed by Lakshmi Vyasarajan
parent
commit
9c7a73fb81
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      hyde/ext/plugins/images.py

+ 6
- 4
hyde/ext/plugins/images.py View File

@@ -253,6 +253,7 @@ class ImageThumbnailsPlugin(Plugin):
im = Image.open(resource.path) im = Image.open(resource.path)
if im.mode != 'RGBA': if im.mode != 'RGBA':
im = im.convert('RGBA') im = im.convert('RGBA')
format = im.format


if preserve_orientation and im.size[1] > im.size[0]: if preserve_orientation and im.size[1] > im.size[0]:
width, height = height, width width, height = height, width
@@ -272,10 +273,11 @@ class ImageThumbnailsPlugin(Plugin):
im = im.crop((shiftx, shifty, width + shiftx, height + shifty)) im = im.crop((shiftx, shifty, width + shiftx, height + shifty))
im.load() 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): def begin_site(self):
""" """


Loading…
Cancel
Save