FAQ
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

Search Discussions

  • Marc 'BlackJack' Rintsch at Jul 24, 2007 at 10:10 am

    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
  • Steve Holden at Jul 24, 2007 at 11:17 am

    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 -------------
  • Ladislav Andel at Jul 24, 2007 at 11:25 am
    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJul 24, '07 at 9:58a
activeJul 24, '07 at 11:25a
posts4
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase