Tags:
2011-08-17

JPEG Quality Argument in GAE SDK 

You might be terribly annoyed (I know I am) by the fact that in the Google App Engine Python SDK the quality argument for JPEG images is ignored which makes it very cumbersome to test out different quality settings. Why it's ignored doesn't really make any sense since PIL (the Python Imaging Library), which the SDK uses to handle images, does supports such an argument.

It makes even less sense when you dig down into the code of the Image API in the GAE SDK and find out just how surprisingly easy this is to change. Here's how to add support for the quality argument: On line 304 in google_appengine/google/appengine/api/images/images_stub.py simply add the argument quality=output_encoding.quality() to the image.save call, or use this patch:

304c304,307
<     image.save(image_string, image_encoding)
---
>     if output_encoding.has_quality():
>       image.save(image_string, image_encoding, quality=output_encoding.quality())
>     else:
>       image.save(image_string, image_encoding)





« PREV PAGE
minON – Minimized Object Notation