[REBOL] Re: jpeg images not working
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 -----
> From: "Tim Johnson" <[tim--johnsons-web--com]>
> To: <[rebol-list--rebol--com]>
> Sent: Wednesday, August 28, 2002 4:37 PM
> Subject: [REBOL] jpeg images not working
>
> > 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
> > *********************************************************************
>
> --
> 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
-- 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
]