[Borges-users] Dynamically creating images with Borges
Слепнев Владимир
slepnev_v at rambler.ru
Mon May 3 16:24:34 EDT 2004
>> data = File.open('plasm.jpg') {|f| f.binmode; f.read} # we have some binary data
>> r.image r.url_for_document(data,"image/jpeg") # we make the image's URL point to this data, with a mime-type
>
>Hm, this way the image is the same for all sessions, isn't it? And the
>URL will not be reclaimed (it will stay forever).
Instead of opening a file, you can fill 'data' with binary data for
the image in some other way. (Capture the output from an SVG renderer,
for example.) The image will be different between different calls to
Controller#render_on (i.e. between different page renders). You can
use some session-specific data to build the image from it, etc. Isn't
this what you want? (This way, you don't really need the proc - you
generate the image data when the page loads, and store it for later
retrieval with #url_for_document.)
The reclaiming part is more tricky, but I'm pretty sure Borges can be
made to expire this properly. If it doesn't do this now (which I'm not
sure of), this will be pretty easy to put in once we have a decent
unit testing framework.
Vladimir Slepnev
P.S. Eric, if I'm wrong in answering questions, correct me, OK?
More information about the Borges-users
mailing list