I'm a bit stuck with my code:
def setVenueImage(img):
img = images.Image(img.read())
x, y = photo_utils.getIdealResolution(img.width, img.height)
img.resize(x, y)
img.execute_transforms()
venue_obj = getVenueSingletonObject()
if venue_obj is None:
venue_obj = Venue(images = [img])
else:
venue_obj.images.append(img)
db.put(venue_obj)
I'm using django with app engine - so img.read() works fine.
In fact all of this code works fine up until I try to store img into the database. My model expects a Blob, so when I put in the image as img, then it throws a fit, and I get:
BadValueError at /admin/venue/ Items in the images list must all be Blob instances
Ok, so an Image must not be a Blob, but then how do I make it a blob? Blobs take in a byte string, but how do I make my image a byte string?
I haven't seen in the docs anywhere where they actually use image objects, so I'm not sure how this is all supposed to work, but I do want to use image objects to resize my image (I know you can do it in PIL, but I'd like to know how to do it with google's Image class).
Thanks for any pointers :)