471,325 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

display image through cgi python html

Hi,
I'm trying to display image through my cgi script in HTML page
via <img src="image.cgi">

Can you give me an example, please?
What should be in the cgi script to display it?

Here is what I have in image.cgi but it is incorrect and i'm not able to
find it on the web.

#!/usr/bin/python
print "Content-Type: image/png\n"
print 'image.png'

thanks,
Lada

Jul 24 '07 #1
3 9657
On Tue, 24 Jul 2007 11:58:47 +0200, Ladislav Andel wrote:
Here is what I have in image.cgi but it is incorrect and i'm not able to
find it on the web.

#!/usr/bin/python
print "Content-Type: image/png\n"
print 'image.png'
You have to print the image, not the name. Read the binary file and print
it.

Ciao,
Marc 'BlackJack' Rintsch
Jul 24 '07 #2
Marc 'BlackJack' Rintsch wrote:
On Tue, 24 Jul 2007 11:58:47 +0200, Ladislav Andel wrote:
>Here is what I have in image.cgi but it is incorrect and i'm not able to
find it on the web.

#!/usr/bin/python
print "Content-Type: image/png\n"
print 'image.png'

You have to print the image, not the name. Read the binary file and print
it.
As in:

#!/usr/bin/python
data = open('image.png', 'rb').read()
print "Content-Type: image/png\nContent-Length: %d\n" % len(data)
print data

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Jul 24 '07 #3
Thanks for quick reply.
Yes, that's the hint I needed.

Lada

Marc 'BlackJack' Rintsch wrote:
On Tue, 24 Jul 2007 11:58:47 +0200, Ladislav Andel wrote:

>Here is what I have in image.cgi but it is incorrect and i'm not able to
find it on the web.

#!/usr/bin/python
print "Content-Type: image/png\n"
print 'image.png'

You have to print the image, not the name. Read the binary file and print
it.

Ciao,
Marc 'BlackJack' Rintsch
Jul 24 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Tompa | last post: by
5 posts views Thread by Peter Lapic | last post: by
3 posts views Thread by David | last post: by
4 posts views Thread by DoomedLung | last post: by
3 posts views Thread by DoomedLung | last post: by
49 posts views Thread by SamFeltus | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.