[REBOL] Re: ANN: Rebol/Flash dialect updated and JPG-analyse
From: pwoodward:cncdsl at: 4-Jan-2002 15:09
Oldes -
here's a link to a document describing the JFIF (what most "JPEG" files are)
format -
http://www.w3.org/Graphics/JPEG/jfif.txt
Typically they define an APPO marker to contain the "resolution" of the
image. However, since the format was derived from a photographic
background, it won't be in simple pixels.
In theory you should be able to parse out the following bytes from a JFIF
(jpg) file:
X'FF', SOI
X'FF', APP0, length, identifier, version, units, Xdensity,
Ydensity, Xthumbnail,
Ythumbnail, (RGB)n
length (2 bytes) Total APP0 field byte count, including
the byte
count value (2 bytes), but excluding the
APP0
marker itself
identifier (5 bytes) = X'4A', X'46', X'49', X'46', X'00'
This zero terminated string ("JFIF")
uniquely
identifies this APP0 marker. This
string shall
have zero parity (bit 7=0).
version (2 bytes) = X'0102'
The most significant byte is used for
major
revisions, the least significant byte
for minor
revisions. Version 1.02 is the current
released
revision.
units (1 byte) Units for the X and Y densities.
units = 0: no units, X and Y specify
the pixel
aspect ratio
units = 1: X and Y are dots per inch
units = 2: X and Y are dots per cm
Xdensity (2 bytes) Horizontal pixel density
Ydensity (2 bytes) Vertical pixel density
Xthumbnail (1 byte) Thumbnail horizontal pixel count
Ythumbnail (1 byte) Thumbnail vertical pixel count
(RGB)n (3n bytes) Packed (24-bit) RGB values for the
thumbnail
pixels, n = Xthumbnail * Ythumbnail
You'll note the X/Y values are stored as a "density" of units - so you may
not be able to quickly determine an image is "320x200" or something
similar... Most screen based pictures will be using a value of 72 dots per
inch.
- Porter
----- Original Message -----
From: <[oliva--david--seznam--cz]>
To: <[rebol-list--rebol--com]>
Sent: Friday, January 04, 2002 2:08 PM
Subject: [REBOL] ANN: Rebol/Flash dialect updated and JPG-analyse
> ANN: Rebol/Flash dialect updated and JPG-analyse
> > Hello...
> I've updated a little bit my Rebol/Flash dialect again so now I'm able to
include bitmaps (as textures or images)...
> You can find updated dialect files and some new examples at:
> http://www.sweb.cz/oliva.david/swf/
>
> Playing with JPGs I've found that some programs (usually from Adobe)
includes some informations in the JPG files that are not so necessary... so
I've created small script that I call %jpg-analyse.r and uploaded this
script to the library. Using this script it is possible to make some of the
JPGs smaller...
> For example:
>
> http://www.rebol.com/view/demos/palms.jpg from 26418 B to 18438 B
> or
> http://www.rebolforces.com/reb/images/smudge.jpg from 6150 B to 2898 B
>
> Now I have more then 11MB free space on my disk thanks to removing these
data from JPG files:-))
> Unfortunatelly I still don't know how to find size (without need to use
Rebol/View) of the jpg image, because I don't have good JPG spec. so if
someone know how to do it, please let me know...