comment on byte-streams

This commit is contained in:
Rolf-Thomas Happe 2003-04-23 17:24:13 +00:00
parent 746040e917
commit 637584b40f
1 changed files with 19 additions and 7 deletions

View File

@ -1,8 +1,8 @@
sunterlib/scsh/image-info -- Extracting Vital Stats from Images sunterlib/scsh/image-info -- Extracting Vital Stats from Images
Loose port of small parts from Marco Schmidt's public domain ImageInfo 1.3 Loose port of small parts from Marco Schmidt's public domain ImageInfo 1.3
Java program. The port supports gif, jpeg, png images and extracts Java program. The port supports gif, jpeg, png images and extracts
* the width and height in pixels, * the width and height in pixels,
* maybe the physical width and height in dpi, * maybe the physical width and height in dpi,
* the (unreliable) colour depth (#bits / pixel), * the (unreliable) colour depth (#bits / pixel),
* a symbolic format id: GIF87A, GIF89A, JPEG, PNG. * a symbolic format id: GIF87A, GIF89A, JPEG, PNG.
@ -13,7 +13,7 @@ local palettes may reset, typically increase, that value.)
The original code, which does much more, is at The original code, which does much more, is at
http://www.geocities.com/marcoschmidt.geo/image-info.html http://www.geocities.com/marcoschmidt.geo/image-info.html
Typical use: in web-authoring, generate the width and height tags of Typical use: in web-authoring, generate the width and height tags of
inline images programmatically, like so: inline images programmatically, like so:
;; ,open image-info ;; ,open image-info
@ -42,7 +42,7 @@ the byte source (input port, file descriptor, byte-vector, b.s.(*))
IMG -- or signal an error. IMG -- or signal an error.
* *
(get-image-info bs) --> info | #f (get-image-info bs) --> info | #f
Synopsis: Extract information on the image represented by b.s.(*) BS Synopsis: Extract information on the image represented by b.s.(*) BS
@ -58,11 +58,11 @@ Get the symbolic format id from image-info record INFO.
Get the colour DEPTH (#bits/pixel) from image-info record INFO. Get the colour DEPTH (#bits/pixel) from image-info record INFO.
(image:info-width/pixel info) --> w | #f (image:info-width/pixel info) --> w | #f
(image:info-height/pixel info) --> h | #f (image:info-height/pixel info) --> h | #f
Get the pixel width W resp. height H from image-info record INFO. Get the pixel width W resp. height H from image-info record INFO.
(image:info-width/dpi info) --> width | #f (image:info-width/dpi info) --> width | #f
(image:info-height/dpi info) --> height | #f (image:info-height/dpi info) --> height | #f
Get the physical width W resp. height H in dots per inch from INFO. Get the physical width W resp. height H in dots per inch from INFO.
* *
@ -72,12 +72,24 @@ Get the physical width W resp. height H in dots per inch from INFO.
Byte-streams, or b.s.s for short, are random-access lazy byte sources. Byte-streams, or b.s.s for short, are random-access lazy byte sources.
The image-info project doesn't commit to the current implementation, The image-info project doesn't commit to the current implementation,
i.e. create and access b.s.s by the procedures below or blame yourself. i.e. create and access b.s.s by the procedures below or blame yourself.
[ Why do we need random-access sources? -- Actually, we don't really.
Random-access buys us a minor architectural edge. We could --just
as Marco Schmidt's original Java program-- read the first two bytes
or so from a port, identify the graphics format and dispatch to the
specialist who deals with the rest of the file. That is, we could
scatter the expertise on graphics formats, with the dispatcher knowing
magic numbers, and others knowing the rest. We could -- but we
choose to encapsulate the expert knowledge on gif, jpeg, png formats
in respective parsing procedures. If one expert cannot parse
a file we ask the next. And while this may not be very wise, it is
conveniently done with b.s.s.
]
(inport->byte-stream in) --> bs (inport->byte-stream in) --> bs
Synopsis: Convert the input port (or file descriptor) IN to a Synopsis: Convert the input port (or file descriptor) IN to a
b.s. BS. (The BS will read from IN as needed. It doesn't duplicate b.s. BS. (The BS will read from IN as needed. It doesn't duplicate
or close IN.) or close IN.)
* *