On Wed, Apr 9, 2008 at 1:14 AM, Gabriel Genellina <<a href="mailto:gagsl-py2@yahoo.com.ar">gagsl-py2@yahoo.com.ar</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">> Thanks. I apparently am printing some holder for the image. I stripped<br>
> out<br>
> most of it with this<br>
> content[0][0]<br>
</div><div class="Ih2E3d">> but then I am left with this:<br>
><br>
> array('c', '\xff\xd8\xff\xe0\\0\x10JFI...)<br>
> How do I extract an image from that?<br>
<br>
</div>print content.tostring()</blockquote><div><br>Now *that* gave me something that *looks* a lot more like an image from a programmers perspective, but still no image...<br>ÿØÿàJFIF...<br>Actually, it does not copy and paste well, but you can see it for the moment here:<br>
<a href="http://livestocksling.com/test/python/Shop/display_es2.py">http://livestocksling.com/test/python/Shop/display_es2.py</a><br>So, how do I convert *that* to a real live image?<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Or perhaps, replace that line with content.tofile(sys.stdout)</blockquote><div><br>Printed nothing.<br> <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">>> >   print 'Content-Type: image/jpeg\r\n'<br>
>> >   print '<html><body>\n'<br>
>> >   print content<br>
>> >   print '</body><html>\n'<br>
>> >   cursor.close()<br>
>> ><br>
>> > test()<br>
<br>
</div><div class="Ih2E3d">>> > The commented out line gives me a leading less than sign...and that´s<br>
>> > it. What do?<br>
<br>
</div>Try to understand now *why* you got a single character with your previous<br>
code.</blockquote><div><br>No clue  :/<br><br>BTW, for purposes of documentation, it appears that, when sending the form with the image to the script that processes the form, the following is inadvisable:<br><br>  form = cgi.FieldStorage()<br>
  pic1 = form.getfirst('pic1', '')<br><br>This appears to work better:<br><br>  form = cgi.FieldStorage()<br>
  imgfile=open("pixel.gif",'rb')<br>
  pixel = imgfile.read()<br>
  pic1 = form.getfirst('pic1', pixel)<br><br>because it gives a binary default. The string appears to screw things up.<br>Victor</div></div>