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

jpeg images not working

 [1/13] from: tim::johnsons-web::com at: 28-Aug-2002 12:37


Hello Rebols: I'm attempting to use rebol to push jpeg images to a a web page. Rendering is not working. The beginning source of this looks as follows (between asterisks): ********************************************************************* HTTP/1.0 200 OK Content-type: multipart/x-mixed-replace; boundary=--myboundary --myboundary Content-type: image/jpeg #{ FFD8FFE000104A46494600010101025802580000FFDB00430001010101010101 0101010101010101010101010101010101010101010101010101010101010101 ********************************************************************* The '#{' appears to be the problem. How to I keep that from appearing? The code to write and write the images is as follows: ..... t: read/binary to-file base-file print copy t ..... How may I correct this? TIA -- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com

 [2/13] from: dockimbel:free at: 28-Aug-2002 23:37


Hi Tim, Try : t: read/binary to-file base-file print enbase/base t 16 HTH, -DocKimbel. Tim Johnson wrote:

 [3/13] from: tim:johnsons-web at: 28-Aug-2002 14:59


* Nenad Rakocevic <[dockimbel--free--fr]> [020828 14:19]:
> Hi Tim, > > Try : > > t: read/binary to-file base-file > print enbase/base t 16
Hi Nenad: After posting this, I tried exactly as you have coded above. I am still getting a broken image. I believe that I may not be "getting" the multipart protocol correctly. What I have below is a capture from the "broken image" icon (with the binary string truncated), below the asterisks: ****************************************************************** HTTP/1.0 200 OK Content-type: multipart/x-mixed-replace; boundary=--myboundary --myboundary Content-type: image/jpeg FFD8FFE000104A4649460 --myboundary ****************************************************************** I've attempted to show the blank lines exactly as they are printed to stdout. <sigh>Ahh! Learning curves... they make me dizzy</sigh> Thanks! -- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com

 [4/13] from: jason:cunliffe:verizon at: 28-Aug-2002 18:46


Hi Tim Are you hoping to use multipart/x-mixed-replace to upload image files to a web site? If so I would love to know more about how that works thanks ./Jason

 [5/13] from: tim:johnsons-web at: 28-Aug-2002 15:47


* Jason Cunliffe <[jason--cunliffe--verizon--net]> [020828 15:35]:
> Hi Tim > > Are you hoping to use multipart/x-mixed-replace to upload image files to a web > site?
Yes!
> If so I would love to know more about how that works
And I'd love to get it to work... (LOL) I'm attaching my rebol code, warts and all, am hacking as i speak. You also might want to look at this link: http://www.axis.com/techsup/cam_servers/tech_notes/live_video_unix.htm
> thanks
And maybe we can learn together. :-) -tim-
> ./Jason > ----- Original Message -----
<<quoted lines omitted: 22>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com -- Attached file included as plaintext by Listar -- #!/usr/bin/rebol -cs REBOL[ Title: "push-image" Date: 26-Aug-2002 File: %push-image.r Purpose: {test image push for web camera} ] testing: none file-name: "gregs-house_CAM1.jpg"; freq: 3 max-images: 10 max-no-update: 30 con-type: "jpeg" base-file: "" same-count: 0 ; write a binary file to STDOUT, buffered if bufreads is greater than 1 binfile-out: func[fname[string! file!] bufreads[integer!] size[integer!] /local fsize blksize remsize fp][ either(fp: open/binary to-file fname)[ either(bufreads < 2)[ ; use 0 or negative to signal unbuffered output prin copy fp ][ either size[ blksize: to-integer size / bufreads remsize: size // bufreads loop bufreads[ prin copy/part fp blksize ] print copy/part fp remsize ][none] ] close fp ][print "file not opened" none] ] ; get MTime for file MTime: func[file[string! file!] /local stat][ either(stat: info? to-file file)[ stat/date][none] ] ; get file size FSize: func[file[string! file!] /local stat][ either(stat: info? to-file file)[stat/size][0] ] print "Content-Type: text/html^/" print "HTTP/1.0 200 OK" print "Content-type: multipart/x-mixed-replace; boundary=--myboundary^/"; print "--myboundary"; ;;;print <pre> either any[system/options/cgi/remote-addr = "127.0.0.1" system/options/cgi/remote-addr = none][ ;;; print "We are local machine" Dir: "../images/camera-1/" file-name: "Bed-Tax-Logo.jpg"; ][ ;;; print "We are on remote machine" testing: false Dir: "../images/camera-1/" file-name: "gregs-house_CAM1.jpg"; ] rounds: 0 base-file: join dir file-name old-image-time: "" same-count: none while[rounds < max-images][ rounds: rounds + 1 time: MTime base-file ;; If the same image time stamp is no the image file for more than ;; the wait period, we presume that the image is not longer updated ;; and end the connection if ((MTime base-file) <> old-image-time)[ same-count: 0 old-image-time: MTime base-file ] if(same-count > (max-no-update * freq))[break] same-count: same-count + 1 rounds: rounds + 1 print rejoin["Content-type: image/" con-type ] ;;;print "HELLO" ;;; binfile-out base-file 10 FSize base-file ;;; binfile-out base-file 0 0 ;;; prin read/binary to-file base-file ;;; write-io system/ports/output t length? t ;;; print length? t ;;; print copy t ;;; print type? t t: read/binary to-file base-file prin enbase/base t 16 print "^/^/--myboundary" break wait .1 ]

 [6/13] from: gchiu:compkarori at: 29-Aug-2002 13:12


On Wed, 28 Aug 2002 15:47:25 -0800 Tim Johnson <[tim--johnsons-web--com]> wrote:
>* Jason Cunliffe <[jason--cunliffe--verizon--net]> [020828 >15:35]:
<<quoted lines omitted: 4>>
>> site? > Yes!
I'm confused. Your code seems to indicate you want to send images to a client browser. There's an example from Allen that shows how to send dynamically created images back to the client in the library somewhere on rebol.org If you want to upload using http to a web server, this snippet from my test suite might help boundary: {--Rj74=$} imagedata: to-string read/binary filename des1: rejoin [ {Content-Disposition: form-data; name="FILE_UPLOAD_FNAME"; filename="} filename {"} ] des2: {Content-Disposition: form-data; name="FILE_UPLOAD_CLAIM_NUM"} des3: {Content-Disposition: form-data; name="FILE_UPLOAD_MD5_SUM"} des4: {Content-Disposition: form-data; name="IMAGE_FILE_ANNOTATION"} postdata: rejoin [ boundary CRLF des2 CRLF CRLF claimno CRLF boundary des3 CRLF CRLF md5 CRLF boundary des4 CRLF CRLF annotation CRLF boundary des1 CRLF CRLF imagedata CRLF boundary "--" CRLF CRLF ] -- Graham Chiu

 [7/13] from: gscottjones:mchsi at: 28-Aug-2002 20:52


From: "Tim Johnson"
> I'm attempting to use rebol to push jpeg > images to a a web page. Rendering is not working.
<<quoted lines omitted: 16>>
> ..... > How may I correct this?
Hi, Tim, I am unfamiliar with "multipart/x-mixed-replace", but I can get the following code to work (note your paths may be different). Maybe you can adapt this to your fancier mime type: #!/path/to/rebol --cgi -s REBOL [] t: read/binary %//rebol/view/nyc.jpg print "Content-type: image/jpeg^/" set-modes system/ports/output [binary: true] foreach u t [insert system/ports/output to-char u] --Scott Jones

 [8/13] from: jason:cunliffe:verizon at: 28-Aug-2002 21:09


> > Are you hoping to use multipart/x-mixed-replace to upload image files to a
web
> > site? > > Yes!
Have you looked at http://www.rebol.org/cgi/POST.html or read the replies here to my recent file upload quesstion? http://www.escribe.com/internet/rebol/m24690.html After resolving server permissions I, *almost* got %post.r *almost* working ok from a cgi form. I can upload files, and its writing them into the default, but so far still not successful understanding the MIME patch suggested in 'comment' section of %post.r Volker's code looks nice, but I still need to put more time and understanding into it. Those all use "multi-part/form". You use "multipart/x-mixed-replace" which is new to me. Why did you opt for it, and what do you know about it?
> I'm attaching my rebol code, warts and all, am hacking as i speak. > You also might want to look at this link: > http://www.axis.com/techsup/cam_servers/tech_notes/live_video_unix.htm > > thanks > > And maybe we can learn together. :-)
Yes hope so. Thanks for the source. I don't know PERL well, so can't follow that very well. I do know there are PHP examples around for uploading images. Easier to read. ./Jason

 [9/13] from: tim:johnsons-web at: 28-Aug-2002 18:40


* Graham Chiu <[gchiu--compkarori--co--nz]> [020828 17:55]:
> On Wed, 28 Aug 2002 15:47:25 -0800 > Tim Johnson <[tim--johnsons-web--com]> wrote:
<<quoted lines omitted: 11>>
> Allen that shows how to send dynamically created images > back to the client in the library somewhere on rebol.org
Thanks Graham: I'm "hacking" perl code provided as an example. You should see examples of the content that I produced in the thread titled "Problems rendering an image", (didn't meant to do it but ending up posting two subjects on the same issue). It's just possible that I may at this time just be in violation of the RFC. I'm not sure that your code is complete, but I might want to revisit it. Do you have a link for Allen's script, (I've used his resources before the multi-part documents)? Thanks -tj-
> If you want to upload using http to a web server, this > snippet from my test suite might help
<<quoted lines omitted: 18>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com

 [10/13] from: tim:johnsons-web at: 28-Aug-2002 19:23


* G. Scott Jones <[gscottjones--mchsi--com]> [020828 18:46]:
> From: "Tim Johnson" > > I'm attempting to use rebol to push jpeg
<<quoted lines omitted: 32>>
> foreach u t [insert system/ports/output to-char u] > --Scott Jones
Thank you Scott: The following code modified by your example with correct paths for my system (between the asterisks) *************************************************************** #!/usr/bin/rebol -cs REBOL [] t: read/binary %../images/camera-1/Bed-Tax-Logo.jpg print "Content-type: image/jpeg^/" set-modes system/ports/output [binary: true] foreach u t [insert system/ports/output to-char u] *************************************************************** Is working intermittenly, but that is better than I've had before, I believe that you're on to something here... I'm in a time zone that puts me currently into the end of my day. Will try again tomorrow morning. Thank you very much! -tim-
> -- > To unsubscribe from this list, please send an email to > [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com

 [11/13] from: gchiu:compkarori at: 29-Aug-2002 16:47


On Wed, 28 Aug 2002 18:40:23 -0800 Tim Johnson <[tim--johnsons-web--com]> wrote:
> I'm not sure that your code is complete, but I might >want to revisit
Yeah, the code is quite incomplete, but is part of a script to hammer a web server by uploading images to it continuously.
> it. Do you have a link for Allen's script, (I've > used his resources before the multi-part documents)? > Thanks
I think from looking again at your script is that all you want to do is display an image in a web page. I don't understand why you are using MIME. This is Allen's image spacer script http://www.rebol.org/web/spacer.html But Scott's script looks as though it should work okay. -- Graham Chiu

 [12/13] from: brett:codeconscious at: 29-Aug-2002 23:05


> I think from looking again at your script is that all you > want to do is display an image in a web page. I don't > understand why you are using MIME.
Don't know if this is of anyhelp but anyways... I think Tim is trying to do server push? Along that route (not done it before reading this thread) I've some marginal success with the script below in Netscape. That is netscape replaces the entity, but IE just returns all the sections. Maybe IE does not understand x-mixed-replace ? Anyway the problem with this script is that it needs to flush the OUTPUT port just prior to the wait but doesn't and I don't know how to do that. Someone else help?! :^) To include the image it will need to be written to the port as binary unless there is an option to encode it as base64 (which would need extra headers and using enbase). If you change the mode of the port to binary (again how?) you need to ensure that the "normal" text lines and headers end in CRLF (the script below relies on REBOL outputing the CRLF as a line ending). Regards, Brett. #!e: /program files/rebol/core/rebol -cs REBOL [ Title: {Server Push Test} Author: {Brett Handley} Date: 29-Aug-2002 Comment: { (1) See http://wp.netscape.com/assist/net_sites/pushpull.html (2) Some success with Netscape, not so with IE. } ] boundary: "ThisRandomString" emit: func [data /local buf] [ print either string? data [data] [rejoin data] ] emit [ {Content-Type: multipart/x-mixed-replace; boundary="} boundary {"} ] emit {} emit [NEWLINE {--} boundary] repeat i 3 [ emit [{Content-Type: text/html} newline] emit [{<h1>} "script-time: " now </h1>] emit [NEWLINE {--} boundary] ; NEED TO FLUSH OUTPUT HERE - HOW? wait 00:00:03 ] emit {} QUIT

 [13/13] from: gchiu:compkarori at: 30-Aug-2002 9:15


On Thu, 29 Aug 2002 23:05:58 +1000 "Brett Handley" <[brett--codeconscious--com]> wrote:
>Along that route (not done it before reading this thread) >I've some marginal
<<quoted lines omitted: 3>>
>does not understand >"x-mixed-replace"?
Hi Brett, I found this: 2) Why do browsers other than Netscape require a java applet? The web camera uses a technique called "server push" which, in theory, is available to any browser fully compliant with the the IETF RFC1521 specification. To see server push, your browser must understand the MIME type multipart/x-mixed-replace . All Netscape browsers since version 1.1 do support this MIME type, however AOL and Microsoft's Internet Explorer browsers are not fully compliant with the standard. A java applet is one way to get around this problem, although there are other ways. Newer versions of Microsoft Internet Explorer are supposed to support multipart/x-mixed-replace, but this is not certain. -- Graham Chiu

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