1. jfinkels
  2. ophot


jfinkels  committed 8a20666

Uploaded photos should be saved with maximum quality using JPEG compression.

  • Participants
  • Parent commits 521608a
  • Branches noimagecompression

Comments (0)

Files changed (1)

File ophot/api/photos.py

View file
 from .queries import Q_UPDATE_PHOTO_DISPLAYPOS
+"""The quality (as an integer between 1 and 100, inclusive) of the JPEG image
+saved after the used uploads an image file to the application.
+A value greater than 95 is not recommended by the Python Image Library; see
+here_ for more information.
+.. _here: http://www.pythonware.com/library/pil/handbook/format-jpeg.htm
 def _get_last_display_position(categoryid):
     """Helper method which returns the index in the display sequence of the
     last photo in the specified category.
         height = int(app.config['SPLASH_PHOTO_HEIGHT'])
         if img.size[0] > width or img.size[1] > height:
             img = img.resize((width, height), Image.ANTIALIAS)
-        img.save(filename, imagetype)
+        img.save(filename, imagetype, quality=IMAGE_QUALITY)
         return make_response(None, 204)
         thumbnail = img.copy()
         thumbnail.thumbnail(app.config['THUMBNAIL_SIZE'], Image.ANTIALIAS)
         # save the image and the thumbnail
-        img.save(long_filename, imagetype)
+        img.save(long_filename, imagetype, quality=IMAGE_QUALITY)
         thumbnail.save(thumbnail_long_filename, imagetype)
         # get the category and display position to set for this photo
         categoryid = int(request.form['categoryid'])