JPEG thumbnail 
Author Message
 JPEG thumbnail

Hello

I have managed to read out the thumbnail information in a JPG/ JPEG file,
and saved it as a new jpg file.
Paint Shop Pro has no problem open it and show the image.
But I cant get it into any control in VB (VB6)
Is there anyone who succeded with this kind of handling?
And please help me with any code example...

regards
Reidar



Tue, 10 May 2005 20:45:13 GMT  
 JPEG thumbnail

Quote:
> I have managed to read out the thumbnail information in a JPG/ JPEG file,
> and saved it as a new jpg file.
> Paint Shop Pro has no problem open it and show the image.
> But I cant get it into any control in VB (VB6)
> Is there anyone who succeded with this kind of handling?
> And please help me with any code example...

Grab the JPEGInfo demo application off my site and see what it makes of it,
if that doesn't reveal a potential problem then post back here what you get
and if the file is small then attach it so we can test it ourselves.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Tue, 10 May 2005 22:34:11 GMT  
 JPEG thumbnail

Quote:
> Mike,
>     Thanks for your answer, Iwe tried your application but it only reported
> "Terminated=False"
>     The JPG file is attached to this message.

Well, I tried to open the JPG with Irfan View and it said that it is a
.PCD file with the wrong extension.

Gale.



Wed, 11 May 2005 02:02:35 GMT  
 JPEG thumbnail

Quote:
>     Thanks for your answer, Iwe tried your application but it only
reported
> "Terminated=False"
>     The JPG file is attached to this message.

First up apologies for not getting round to this sooner, I've been busy this
week though.  I had a dig through your image in a hex editor and the JPEG
format specification and found the 'problem' for you - It's actually not a
problem with your image as such, but the half-hearted JPEG loading methods
that are being used by Microsoft.  If you're into the nitty-gritty of things
then have a look at the file in a hex editor (If not, skip down to
"Anyway"), you'll see the first 15 bytes as:

FFFF FFFF FFFF FFFF FFFF FFFF FFFF D8

Now JPEG is a chunked/tagged based format and for the file to be assumed as
valid it must start with a "Start or image" (Or "SOI") tag.  A JPEG tag is
declared as marker byte of 0xFF followed by a second byte < 0xFF describing
the type of tag.  The SOI tag is 0xFFD8 so when the JPEG import application
first opens the file it has to ensure it's validity by checking for the
existence of the SOI tag however as you'll see here the first two bytes are
0xFFFF so a basic check (Including the one in the JPEGInfo class
unfortunately) simply throw this out an assume that this is either a broken
file or another file type re-named to .JPG.  While digging through the
specification I stumbled upon this statement on page 35:

<quote>
All markers are assigned two-byte codes: an X'FF' byte followed by a byte
which is not equal to 0 or X'FF' (see Table B.1). Any marker may optionally
be preceded by any number of fill bytes, which are bytes assigned code X'FF'
.
</quote>

Something which I'd (And obviously Microsoft too) overlooked.  The even more
alarming thing is that IE doesn't recognise the image either which uses the
IJL DLL for it's JPEG import (We think, at least that's what it states in
the "about" screen), so even the makers of the format can't get it right?
Hmm..  I've now fixed my library and there will be an updated version posted
to my site soon that accommodates this.

Anyway, to cut a long story short simply trim this extra padding (The first
13 0xFF bytes) off the start of the image data and it will load just fine.
Your image data is trimmed at the end though so you may want to re-think the
method you're using to extract the thumbnail images, or just look for a "End
of image/EOI" tag (0xFFD9) in the source data and use that as the end of the
thumbnail data.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Fri, 13 May 2005 00:32:20 GMT  
 JPEG thumbnail
On Sun, 24 Nov 2002 16:32:20 -0000, "Mike D Sutton"

Quote:

> Anyway, to cut a long story short simply trim this extra padding (The first
> 13 0xFF bytes) off the start of the image data and it will load just fine.
> Your image data is trimmed at the end though so you may want to re-think the
> method you're using to extract the thumbnail images, or just look for a "End
> of image/EOI" tag (0xFFD9) in the source data and use that as the end of the
> thumbnail data.

I refer the honourable gentleman to the post I  made earlier. Irfan
View reckoned that afil.jpg was a .PCD file with the wrong extension.
Asked if I wanted to change the extension, I said Yes, and it opened
the file with no problem.

Gale.



Fri, 13 May 2005 03:05:26 GMT  
 JPEG thumbnail

Quote:
> I refer the honourable gentleman to the post I  made earlier. Irfan
> View reckoned that afil.jpg was a .PCD file with the wrong extension.
> Asked if I wanted to change the extension, I said Yes, and it opened
> the file with no problem.

I'm not familiar with the internal structure of a .PCD file, however I've
manually been though the binary attachment posted previously in this thread
in a HEX editor and it was formatted correctly as a .JPEG image (Apart from
having the image data clipped, you can see the visual anomalies in the
bottom right corner of the image though which verify this).  The two formats
may be quite similar though, or their .PCD I/O module is a reasonably
generic format that encapsulated a number of basic parses so if nothing else
works, throw it at that (A general test for SOI and EOI tag's in this file
would fail which would likely through the image out as not being a JPEG in
most parsers, the EOI tag is often less important though since the format is
streamable and has to in theory deal with partially transferred image
streams.  The additional padding on the SOI tag is probably what threw it,
try the clipped file in Irfan View and see what it makes of it.)
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Fri, 13 May 2005 04:05:18 GMT  
 JPEG thumbnail
On Sun, 24 Nov 2002 20:05:18 -0000, "Mike D Sutton"

Quote:

> I'm not familiar with the internal structure of a .PCD file, however I've
> manually been though the binary attachment posted previously in this thread
> in a HEX editor and it was formatted correctly as a .JPEG image (Apart from
> having the image data clipped, you can see the visual anomalies in the
> bottom right corner of the image though which verify this).

PCD is Kodak Photo CD format.

Well, I thought that Irfan View had opened the file OK, but it hadn't.
The "picture" it showed was just vertical coloured lines which I had
assumed were an intended pattern.

Paint Shop Pro 7 said the file was "corrupted".
MGI Photo Suite said it was "invalid".
Office failed to import it with any filter.
Greenstreet's Photo FX was the only app of mine that opened it
successfully, so I saw a picture of a baby with the visual anomalies
of which you spake.

Quote:
> The additional padding on the SOI tag is probably what threw it,
> try the clipped file in Irfan View and see what it makes of it.)

I haven't seen a clipped version. Have you posted something I've
missed?

Gale.



Fri, 13 May 2005 05:15:09 GMT  
 JPEG thumbnail
Hi Gale,

Quote:
> PCD is Kodak Photo CD format.

> Well, I thought that Irfan View had opened the file OK, but it hadn't.
> The "picture" it showed was just vertical coloured lines which I had
> assumed were an intended pattern.

Would this be their native/preferred image format by any chance?  As I said,
I don't know the format very well (And couldn't find any files round here to
have a dig through) and the only document on wotsit.org on the format left
something to be desired however from what I could ascertain the two format's
look quite different.

Quote:
> Paint Shop Pro 7 said the file was "corrupted".
> MGI Photo Suite said it was "invalid".
> Office failed to import it with any filter.
> Greenstreet's Photo FX was the only app of mine that opened it
> successfully, so I saw a picture of a baby with the visual anomalies
> of which you spake.

> I haven't seen a clipped version. Have you posted something I've
> missed?

<quote>
Anyway, to cut a long story short simply trim this extra padding (The first
13 0xFF bytes) off the start of the image data and it will load just fine.
</quote>

Although *technically* speaking it is a valid JPEG with the pre-tag padding
it seems that many import routines won't accept this.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Fri, 13 May 2005 05:58:13 GMT  
 JPEG thumbnail


Quote:
>Hello

>I have managed to read out the thumbnail information in a JPG/ JPEG file,
>and saved it as a new jpg file.
>Paint Shop Pro has no problem open it and show the image.
>But I cant get it into any control in VB (VB6)
>Is there anyone who succeded with this kind of handling?
>And please help me with any code example...

        http://pmilligan.net/JPEGMaker.zip  Free, with source code.

        I  ain't saying it's pretty, I'm saying it works.  For a
server-side or batch process it will do just fine.


Quote:
>~~>~~>~~>~~>~~>~~>~~>~~>~~>~~>~~>~~>~~>~~>~~>~~>~~>~~>~~

Please look at http://helpthecritters.com/ , my new domain for helping critters !!!

My personal WWW site is at  http://www.pmilligan.net ,
featuring free HVAC, stock market, and other free software

Those who say a thing can not be done
should get out of the way of those
who are actually doing it.



Fri, 13 May 2005 08:17:38 GMT  
 JPEG thumbnail
On Sun, 24 Nov 2002 21:58:13 -0000, "Mike D Sutton"

Quote:

> Would this be their native/preferred image format by any chance?  As I said,
> I don't know the format very well (And couldn't find any files round here to
> have a dig through) and the only document on wotsit.org on the format left
> something to be desired however from what I could ascertain the two format's
> look quite different.

PCD is certainly not Irfan View's "preferred" format - Irfan View is a
general purpose (and free) viewer that will open just about any still
or movie action or sound file in the known universe. There must have
been something about this particular file that made it think it was
PCD.

Quote:
> Anyway, to cut a long story short simply trim this extra padding (The first
> 13 0xFF bytes) off the start of the image data and it will load just fine.
> </quote>

Yes, with that little edit, Irfan View (and others) now open the file
as a JPG without complaint.

Well sleuthed! <g>

Gale.



Fri, 13 May 2005 08:16:50 GMT  
 JPEG thumbnail
Mike,
Thanks for all your professional help, now the thumbnail application is
working just fine.

regards
Reidar



Quote:
> >     Thanks for your answer, Iwe tried your application but it only
> reported
> > "Terminated=False"
> >     The JPG file is attached to this message.

> First up apologies for not getting round to this sooner, I've been busy
this
> week though.  I had a dig through your image in a hex editor and the JPEG
> format specification and found the 'problem' for you - It's actually not a
> problem with your image as such, but the half-hearted JPEG loading methods
> that are being used by Microsoft.  If you're into the nitty-gritty of
things
> then have a look at the file in a hex editor (If not, skip down to
> "Anyway"), you'll see the first 15 bytes as:

> FFFF FFFF FFFF FFFF FFFF FFFF FFFF D8

> Now JPEG is a chunked/tagged based format and for the file to be assumed
as
> valid it must start with a "Start or image" (Or "SOI") tag.  A JPEG tag is
> declared as marker byte of 0xFF followed by a second byte < 0xFF
describing
> the type of tag.  The SOI tag is 0xFFD8 so when the JPEG import
application
> first opens the file it has to ensure it's validity by checking for the
> existence of the SOI tag however as you'll see here the first two bytes
are
> 0xFFFF so a basic check (Including the one in the JPEGInfo class
> unfortunately) simply throw this out an assume that this is either a
broken
> file or another file type re-named to .JPG.  While digging through the
> specification I stumbled upon this statement on page 35:

> <quote>
> All markers are assigned two-byte codes: an X'FF' byte followed by a byte
> which is not equal to 0 or X'FF' (see Table B.1). Any marker may
optionally
> be preceded by any number of fill bytes, which are bytes assigned code
X'FF'
> .
> </quote>

> Something which I'd (And obviously Microsoft too) overlooked.  The even
more
> alarming thing is that IE doesn't recognise the image either which uses
the
> IJL DLL for it's JPEG import (We think, at least that's what it states in
> the "about" screen), so even the makers of the format can't get it right?
> Hmm..  I've now fixed my library and there will be an updated version
posted
> to my site soon that accommodates this.

> Anyway, to cut a long story short simply trim this extra padding (The
first
> 13 0xFF bytes) off the start of the image data and it will load just fine.
> Your image data is trimmed at the end though so you may want to re-think
the
> method you're using to extract the thumbnail images, or just look for a
"End
> of image/EOI" tag (0xFFD9) in the source data and use that as the end of
the
> thumbnail data.
> Hope this helps,

>     Mike

>  -- EDais --

>  - Microsoft Visual Basic MVP -
> WWW: Http://EDais.earlsoft.co.uk/





Sat, 14 May 2005 17:16:24 GMT  
 JPEG thumbnail

Quote:
> Thanks for all your professional help, now the thumbnail application is
> working just fine.

You're welcome, was the rest of the thumbnail in the original file?

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Sat, 14 May 2005 17:53:35 GMT  
 JPEG thumbnail
I made it simple for me and just cut the wrong information in thumbnail
binary file, then it was no problem
loading the image.
I got all the thumnail data direct from the original fil, using
(JPEGInterchangeFormat) as offset in the binary file and get
(JPEGInterchangeFormatLength) number of bytes.
Decreasing with 13 bytes as you said, in a later version I will seek the
correct start and stop byte before i create the thumbnail.
That's all and it works fine for now.

Some example (for other readers......)
Open "c:\out.jpg" For Binary As #iOutFile
Open "C:\in.jpg" For Binary As #iInFile
sBuffer = String(iThumbLength - 13, " ")
Get #iInFile, iThumbOffset + 13, sBuffer
Put #iOutFile, , CStr(sBuffer)
Close iOutFile
Close iInFile

/reidar



Quote:
> > Thanks for all your professional help, now the thumbnail application is
> > working just fine.

> You're welcome, was the rest of the thumbnail in the original file?

>     Mike

>  -- EDais --

>  - Microsoft Visual Basic MVP -
> WWW: Http://EDais.earlsoft.co.uk/





Sat, 14 May 2005 20:41:33 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. How can I show an JPEG thumbnail?

2. GENERATE JPEG THUMBNAIL

3. Thumbnail Control or Algorithm for making thumbnails!!!!!!

4. JPEG VBX - jpeg.txt [1/1]

5. jpeg thumbnailer -- need jpeg control or code

6. How to retrieve still Jpeg images from Jpeg AVI File

7. File Open Dialog with thumbnails

8. Word Thumbnails

9. Thumbnails (again).....this time for movies

10. W2K thumbnail control

11. DSOFile and Thumbnails

12. Document thumbnail image display

 

 
Powered by phpBB® Forum Software