Book Image

Mastering Google App Engine

Book Image

Mastering Google App Engine

Overview of this book

Table of Contents (18 chapters)
Mastering Google App Engine
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Images


Just because it is useful to some extent, we are going to talk about the image processing capabilities that are available to you on Google App Engine. They might not be as sophisticated as you'd expect from other image processing libraries in other languages, but they are still good enough for most common cases in web applications.

The entire functionality resides in the google.appengine.api.images module. The main class here is Image, which can be initialized with raw binary data like this:

image = Image(image_data=data)
where data can be from a file or from request like this:
class ImageResize(webapp2.RequestHandler):
    def post(self):
        # photo is an <input type='file'> from HTML request
        photo = self.request.params.get('photo')
        # photo is FieldStorage class which has file attribute which is like a file object.
        image = images.Image(image_data=photo.file.read())

The Image class can also be initialized from Blobstore if you have a blob key as a string...