× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: Retrieving JPG and GIF file data in an AS/400 program
  • From: "John Taylor" <john.taylor@xxxxxxxxxxxxxxx>
  • Date: Wed, 30 Aug 2000 19:11:55 -0600

Rob,

You've picked a fairly hairy subject to jump into.

JPEG is not in itself a file format - it's a compression scheme. The
compressed image can be embodied in various different file structures. There
is JFIF (a pseudo-standard), PICT (from the macintosh) and various
proprietary formats. The most common format is the JFIF file, and it can be
found in 3 different versions; 1.0, 1.01, and the current 1.02.

I'm hardly an expert on this stuff, so I'll confine my explanation to the
JFIF 1.02 format only.

The file is segmented in variable sized blocks called "markers". Each marker
always begins with x'FF. There is a specific sequence to the markers, as
follows:

The first marker is called the SOI, for start of image. It is at offset 0,
and is 2 bytes long. It is identified as x'FF D8.

The next marker is called the APP0. It is the identification "label" for the
JFIF file. This is a variable length marker that has a specific structure,
and provides information about the file type/version etc. The only part of
this marker that you need are the first two bytes. They represent the byte
length of the marker, and would be found at offset 2 (from beginning of
file). You'll use the byte length to skip this marker. The structure looks
like this:

length (2 bytes)
identifier(5 bytes)
version(2 bytes)
units (1 bytes )
Xdensity  (2 bytes)
Ydensity (2 bytes)
Xthumbnail (1 byte)
Ythumbnail (1 byte)
(RGB)n  (3n bytes)

You'll know you've found this marker if you see the zero terminated string
"JFIF" at offset 6. The hex representation will look like x'4A 46 49 46 00.

The marker that we're interested in is called an SOF, or "start of frame"
marker. Explaining how to get to it will take more time than I have
available right now, so I'll leave that for tommorow. In the meantime, open
up a jpg file in your favourite hex editor (Wordpad doesn't do hex - does
it?), and see if you can spot the APP0 marker.

We may want to consider taking this offline from here. It has little to do
with list topic, and is probably of little or no interest to the group.


Regards,

John Taylor
Canada

Rob Dixon wrote:

> I have had a look at these links but I am not really any the wiser.
Please
> excuse my stupidity but I couldn't understand how to identify the SOFn
byte
> pair.
> I have looked at a JPEG file using Wordpad but, even though I knew the
size
> of
> the image, I could not identify the values in the header.
>
> I would like to do the work in my AS/400 rather than on a PC as part of a
> routine
> to load the jpeg file names and image size data into my AS/400 database.
If
> I
> knew how to identify the byte pair, then I imagine that I could do the
job.
> Do
> you know if there woud be any code page issues.
>
> Best wishes
>
> Rob
> ________________________________________________________
>
> Erros plc
>
> 44 (0) 1844 239 339
>
> http://www.erros.co.uk - The AS/400 Neural Database for the Internet


+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.