Generating Thumbnails Without PIL

301 views
Skip to first unread message

tj9991

unread,
Apr 20, 2008, 3:35:23 PM4/20/08
to Google App Engine
Hi there. I'd like to hear from everyone on solutions to my problem,
regarding Google not allowing use of the python image library.

For one of my applications, users can upload images, which are
attached to their posts. These images, under normal circumstances,
are displayed on the page as small thumbnails, and a user can click
the thumbnail to go to the full sized image.

The problem here is that I can not currently generate thumbnails.
Right now I just place an img HTML element in the page with the
correct aspect ratio of the original image, making it look like a
thumbnail. This is, of course, not what I want as the end result, as
it simply is resizing the original image, which does not help with
bandwidth or download time.

Is there any way I can work around this until Google adds PIL?

Ross Ridge

unread,
Apr 20, 2008, 3:59:43 PM4/20/08
to Google App Engine
tj9991 wrote:
> Is there any way I can work around this until Google adds PIL?

I don't think so. Decompressing a GIF or an JPEG in pure Python code
would probably take too long even for an already thumbnail sized
image. You might able to do it with PNG's, if the zlib module is
supported by the App Engine, and you use a simple "delete every N'th
pixel" type scaling algorithim.

Ross Ridge

Anthony

unread,
Apr 20, 2008, 7:08:06 PM4/20/08
to Google App Engine
You could do the upload & thumbnail with Flash, but I think its only
supported in Flash 9 so you would be limiting your visitors to that.

David_V

unread,
Apr 21, 2008, 10:40:00 AM4/21/08
to Google App Engine
I have a very similar need, but without PIL it's a non starter. The
only solution I can think of, at this time, is to use a 3rd party site/
service that resizes the thumbnails for you. I haven't followed this
up.

Using a 3rd party has it own issues I think:
* means uploading from GAE or from the user's browser directly to the
3rd party server. Going from GAE would likely run into the script
execution time limit.
* then later when the 3rd party service completed processing the image
you would need to get it back. This could be tricky without CRON jobs.

Sebastian Aviña

unread,
May 3, 2008, 10:24:49 AM5/3/08
to Google App Engine
use picasa

Matteo Crippa

unread,
May 3, 2008, 10:35:45 AM5/3/08
to Google App Engine
You should try to do something with URL.fetch and an external site
with a simple PHP GD script that allow you to remote resize imgs.

You can:

Upload your full size pic to GAE, then using URL.fetch call for that
page with reference to the pic stored in GAE
Then add in the db the referece to the thumb.

So:

Upload pic to GAE -> GAE calls to resize -> resize output is stored in
db

In this way you will store both full and thumb version, btw you can
decide to store only the thumb one modify the pic value in your db.

Ninjamonk

unread,
May 3, 2008, 11:08:26 AM5/3/08
to Google App Engine
Its clever way round but kinda defeats the purpose of using appengine.
maybe image tools need adding to appengine.

I have a simular problem, I want to limit the image diminesions of the
image uploaded and without image tools its a non starter. pretty
simple stuff but I guess its a beta.

If anyone has an idea about how I can get this info out of the blob
please share :P

Cheers

tj9991

unread,
May 3, 2008, 11:26:28 AM5/3/08
to Google App Engine
You can get the dimensions of any PNG, GIF, or JPG image using a pure
python function called getImageInfo

You can find the function in my appengine source file at
http://code.google.com/p/pyib/source/browse/trunk/pyib.py

Also, if anyone was wondering, I've been thumbnailing my images using
an external resource, which you can read about at
http://groups.google.com/group/google-appengine/browse_thread/thread/67d4adf00c3d5c39

majek04

unread,
May 3, 2008, 2:23:30 PM5/3/08
to google-a...@googlegroups.com
> Also, if anyone was wondering, I've been thumbnailing my images using
> an external resource, which you can read about at
> http://groups.google.com/group/google-appengine/browse_thread/thread/67d4adf00c3d5c39

Exactly. I created external web service that can resize images.

Example application is here:
http://srv.appspot.com/gallery/

Source code:
http://code.google.com/p/gae-services-examples/source/browse
trunk/srv/gallery

Documentation draft:
http://movq.net/#images-resizing-service

Cheers!
Marek Majkowski

Sebastian Aviña

unread,
May 6, 2008, 4:40:25 AM5/6/08
to Google App Engine
I'm using Gallery Export, it's standalone, programmed in java, and can
automate bulk uploading.

manatlan

unread,
May 6, 2008, 6:27:05 PM5/6/08
to Google App Engine

tj9991

unread,
May 6, 2008, 6:36:42 PM5/6/08
to Google App Engine
Do you even know what you're talking about, manatlan?

That does not provide any kind of "full python" (as you put it)
library, it simply provides external resources which you can utilize
using urlfetch.

Also, that thumbnail service doesn't support GIFs. I'm not sure how
you can call something a thumbnailer without supporting one of the big
three image file formats.

On May 6, 3:27 pm, manatlan <manat...@gmail.com> wrote:
> another way here, to stay in full python :http://manatlan.com/blog/utilitymill_to_do_what_is_impossible_to_do_o...

manatlan

unread,
May 8, 2008, 3:57:29 AM5/8/08
to Google App Engine
@tj9991

> Do you even know what you're talking about, manatlan?

sure

> That does not provide any kind of "full python" (as you put it)
> library, it simply provides external resources which you can utilize
> using urlfetch.

it provides a simple way to build restful webservice, which can be
build with python, and many other python libs ...
(so you can code in python on utilitymill, and code in python in gae)
After that, you consume your webservice easily with urlfetch

And so, you can easily consume a thumbnailer webservice ...

> Also, that thumbnail service doesn't support GIFs.

I've just added GIF support to this restful webservice (it took me
2secs, just added GIF in the dropdown) ... see here :
http://utilitymill.com/utility/Create_Thumbnail
(note it provides full pil support, so you can do all what you can do
with pil)

> I'm not sure how
> you can call something a thumbnailer without supporting one of the big
> three image file formats.

use the code, luke !
Reply all
Reply to author
Forward
0 new messages