[Zope] Returning a pil generated image from a python product
Sean K
getmejazzed@yahoo.com
Tue, 19 Nov 2002 14:43:51 -0800 (PST)
--0-1061187172-1037745831=:48266
Content-Type: text/plain; charset=us-ascii
I am writing a product that returns an image generated by pil (unfortunately it doesn't):
Create image-
im = PIL.Image.new('RGB',(width,height))
it is then drawn-
draw = ImageDraw.Draw(im)
draw.rectangle([0,0,width,height], fill=(250,250,250)) etc etc etc
after it is ready to be sent out I "save" it -
pic = cStringIO.StringIO()
im.save(pic, 'GIF')
and send it
pic.seek(0)
RESPONSE.setHeader("Content-type", "image/gif")
RESPONSE.write(pic.read())
my index_html
<dtml-var standard_html_header>
<IMG src="./dynamicImage?RESPONSE=RESPONSE">
<dtml-var standard_html_footer>
the product class inherits Item, Persistent and Implicit
the dynamicImage method has an argument RESPONSE
When I click on view all I get is an image placeholder box (true as well when using the same image tag in a dtml method in the root folder), however from a dtml method in the root folder <dtml-var expr="TestObject.dynamicImage(RESPONSE)"> will render an image as the only content. any other content in the method is ignored.
This is my first attempt at a product, so after much hair pulling I must get it to work.
Thank you in advance for any help
Sean K
---------------------------------
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
--0-1061187172-1037745831=:48266
Content-Type: text/html; charset=us-ascii
<P>I am writing a product that returns an image generated by pil (unfortunately it doesn't): </P>
<P>Create image-</P>
<P>im = PIL.Image.new('RGB',(width,height))</P>
<P>it is then drawn-</P>
<P>draw = ImageDraw.Draw(im)</P>
<P>draw.rectangle([0,0,width,height], fill=(250,250,250)) etc etc etc</P>
<P>after it is ready to be sent out I "save" it -</P>
<P>pic = cStringIO.StringIO()<BR>im.save(pic, 'GIF')</P>
<P>and send it</P>
<P> pic.seek(0)<BR> RESPONSE.setHeader("Content-type", "image/gif")<BR> RESPONSE.write(pic.read())</P>
<P> </P>
<P>my index_html</P>
<P><dtml-var standard_html_header><BR><IMG src="./dynamicImage?RESPONSE=RESPONSE"><BR><dtml-var standard_html_footer></P>
<P> </P>
<P>the product class inherits Item, Persistent and Implicit</P>
<P>the dynamicImage method has an argument RESPONSE</P>
<P>When I click on view all I get is an image placeholder box (true as well when using the same image tag in a dtml method in the root folder), however from a dtml method in the root folder <dtml-var expr="TestObject.dynamicImage(RESPONSE)"> will render an image as the only content. any other content in the method is ignored.<BR></P>
<P>This is my first attempt at a product, so after much hair pulling I must get it to work.</P>
<P>Thank you in advance for any help</P>
<P>Sean K</P><p><br><hr size=1>Do you Yahoo!?<br>
<a href="http://rd.yahoo.com/hosting/mailsig/*http://webhosting.yahoo.com">Yahoo! Web Hosting</a> - Let the expert host your site
--0-1061187172-1037745831=:48266--