Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Outputting Image from CGI...

 [1/11] from: jean:holzammer:faedv-n:bayern at: 6-Aug-2001 8:21


Hi, I have a cgi script that should read a picture file (cnt.png) and output it. I have this piece of code: print "Content-Type: image/png" print ["Content-Length:" size? %cnt.png] print "" print read/binary %cnt.png but printing a binary results in printing the rebol string representation of a binary! Instead of showing the image, the browser shows a text like this: #{ 89504E470D0A1A0A0000000D494844520000001E0000000A08020000002C1579 780000001374455874536F667477617265005245424F4C2F566965778FD91678 0000004D49444154789C63F8FF5F904688811E46BB30B800117ED5B81440F4A2 99C080AC07BFD1B8ECC6A58B811845F8ED467632165713F42F1E056882702EB1 46E3721A61A3F1E8A4341A698168683400AD6C267FCACBFB770000000049454E 44AE426082 } Any ideas ? Jean

 [2/11] from: dockimbel:free at: 6-Aug-2001 10:43


Hi Jean, Try : print to-string read/binary %cnt.png HTH, DocKimbel. Holzammer, Jean wrote:

 [3/11] from: jean:holzammer:faedv-n:bayern at: 6-Aug-2001 13:43


> Try : print to-string read/binary %cnt.png
This results in an invalid image file. I compared the original and the downloaded image file using a hex editor to-string seems to convert any occurence of (hex) 0D 0D to 0D 0A ! ,ie 2 linefeed to linefeed + carriage return I also tried this here: foreach x read/binary %cnt.png [prin to-char x] similar result,; maybe prin itself does a newline character conversion itself ? ??? Jean

 [4/11] from: dockimbel:free at: 6-Aug-2001 15:21


Hi Jean, Holzammer, Jean wrote:
> > Try : print to-string read/binary %cnt.png > > This results in an invalid image file. > > I compared the original and the downloaded image file using a hex > editor > > to-string seems to convert any occurence of (hex) 0D 0D to 0D 0A ! > ,ie 2 linefeed to linefeed + carriage return
I don't think that your cgi script is doing something wrong :
>> to-binary probe to-string #{0D0D0A0D}
{^M^M ^M} == #{0D0D0A0D} Seems Ok for me. It may be that your browser is not supporting PNG, try with a GIF image. HTH, DocKimbel.

 [5/11] from: jean:holzammer:faedv-n:bayern at: 6-Aug-2001 15:38


>I don't think that your cgi script is doing something wrong : >>> to-binary probe to-string #{0D0D0A0D}
<<quoted lines omitted: 3>>
>Seems Ok for me. >It may be that your browser is not supporting PNG, try with a GIF
image. It's Internet Explorer 5.5, should support png; I also tried it with .bmp files. same result. Gif is not an option as the image file is created using rebol (I'm working on a graphical web counter); Jean

 [6/11] from: chris:starforge:demon at: 6-Aug-2001 15:10


Holzammer, Jean wrote:
> Gif is not an option as the image file is created using rebol (I'm > working on a graphical web counter);
One alternative - Draw your images individually, save them on your website as normal. Then use a script in an iframe to output html to show the counter using a series of IMG tags. Not quite as neat, but it works. I've got a script you can work from (although it's rather old) on http://www.starforge.co.uk/downloads.html Chris -- .------{ http://www.starforge.co.uk }-----. .--------------------------. =[ Explorer2260, Designer and Coder \=\ P: TexMaker, ROACH, site \ =[___You_will_obey_your_corporate_masters___]==[ Stack: EETmTmTRRSS------ ]

 [7/11] from: g:santilli:tiscalinet:it at: 6-Aug-2001 19:31


Hello Jean! On 06-Ago-01, you wrote: HJ> to-string seems to convert any occurence of (hex) 0D 0D to HJ> 0D 0A ! ,ie 2 linefeed to linefeed + carriage return The culprit is not TO-STRING, but the fact that system/ports/output is not opened as binary. Try: port: open/binary console:// insert port read/binart %image.png close port or use SET-MODES on system/ports/output. Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [8/11] from: ryanc::iesco-dms::com at: 7-Aug-2001 15:39


Coincidentally I am trying to implement a image logger, but so far I am having a problem getting nulls across. example:
>> gif-cgi: read/binary http://www.iesco-dms.com/line.r
== #{ 474946383961C80191FFFFFE010221F9040414FF2CC801020C848FA9CBED0FA3 9CB4DAEB0A3B }
>> gif-file: read/binary http://www.iesco-dms.com/line.gif
== #{ 474946383961C80001009100000000FF0000FFFE010200000021F904041400FF 002C00000000C800010000020C848FA9CBED0FA39CB4DAEB0A003B }
>>
Here is the code I have been tooling around with: ---------------- #!/usr/local/bin/rebol/rebol -cs REBOL[] prin "Content Type: image/gif" prin to-char 10 prin to-char 10 ;set-modes system/ports/output [binary: true] prin to-string read/binary %line.gif ;con: open/binary console:// ;insert con read/binary %line.gif ;close con ---------------- As you can see from my commented code, I have tried several methods. I have tried this on Xitami under win98 using REBOL/Core 2.5.0.3.1, and Apache under Linux running REBOL/Core 2.3.0.6.1. I get nothing at all when I open a console port.
>> gif: read/binary http://www.iesco-dms.com/line-con.r ;console
version of the cgi == #{}
>>
Any ideas, hints, pointers, suggestions, outright rude remarks, and/or sentiments are welcome. --Ryan Gabriele Santilli wrote:
> Hello Jean! > On 06-Ago-01, you wrote:
<<quoted lines omitted: 16>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst www.iesco-dms.com 707-468-5400

 [9/11] from: allenk:powerup:au at: 8-Aug-2001 17:07


Ryan, There is a script (spacer.r) on rebol.org that I did ages ago, it generates and returns a 1x1 colored .gif basically the final output is print "Content-Type: image/gif^/" write-io system/ports/output gif length? gif scripts that might be useful to look at http://www.rebol.org/cgi/spacer.html http://www.rebol.org/cgi/gif-number.html Cheers, Allen K

 [10/11] from: jean:holzammer:faedv-n:bayern at: 8-Aug-2001 15:37


>basically the final output is >print "Content-Type: image/gif^/" >write-io system/ports/output gif length? gif
This worked for me ! Thanks a lot. Jean

 [11/11] from: ryanc:iesco-dms at: 8-Aug-2001 9:28


'Write-io works beautifully Allen! Thanks! --Ryan Allen Kamp wrote:
> Ryan, > There is a script (spacer.r) on rebol.org that I did ages ago, it generates
<<quoted lines omitted: 109>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst www.iesco-dms.com 707-468-5400

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted