On Fri, 18 Sep 2009 12:06:09 -0700 (PDT), Dan King <[email protected]>
wrote:
>> If you have command line or PHP access (perhaps some other language) for
>> sure. You can write a job that is either activated every time you load
>> a page (it will call the script, probably 'convert') or alternately runs
>> like a daemon or activated by cronjob and runs hourly. This need not be
>> complicated. If the images are mixed portrait or landscape we feed it
>> an option to scale to height or width, depending on need. I don't know
>> Python but I assume you can call a script, perhaps using the 'system' or
>> similar python command?
>
> Via python's 'system' function I have access to the command line, which
> thus allows me to create the thumbnails on demand. The drawback is that
> rather than creating a resource that I can output to a browser it
actually
> creates a file. Previously, using GD & PHP I was able to create thumbnail
> resources on demand that I could output to the browser. Is this possible
> with IM?
The flipside of this is generating thumbnails "on the fly" means you can't
cache the operation to avoid regenerating the same thumbnail on every page
view. Unless your source images are constantly changing, or the thumbnail
must contain dynamic elements, it'll place a lot of unnecessary load on
your box if you don't generate the images to files (if not already
existing) and then serve the files instead.
That all said, what you want is to write your image to a StringIO object
instead of a file, and then stream that to the browser by appending the
content type header.. something like
print "Content-type: image/jpeg\n"
f.seek(0)
print f.read()
where f is a StringIO object you've "written" an image to.
http://lost-theory.org/python/dynamicimg.html
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users