JUCE can't read embedded JPG


#1

I’ve written a part of code that finds the picture in MP3s and reads them out. So far it works well, and most JPEG’s will be embedded as “image/jpg (or jpeg)” MIME type. I can read them using JUCE’s JPEGImageFormat. However, I found one that is just embedded as “JPG” and, although it is a JPG, JUCE can’t seem to properly read it. Windows explorer shows it well. Here’s the data of the first bytes:

This is with JUCE146.

[0x0] 0x10 '␐' unsigned char [0x1] 0x4a 'J' unsigned char [0x2] 0x46 'F' unsigned char [0x3] 0x49 'I' unsigned char [0x4] 0x46 'F' unsigned char [0x5] 0x00 unsigned char [0x6] 0x01 '␁' unsigned char [0x7] 0x01 '␁' unsigned char [0x8] 0x01 '␁' unsigned char [0x9] 0x00 unsigned char [0xa] 0x64 'd' unsigned char [0xb] 0x00 unsigned char [0xc] 0x64 'd' unsigned char [0xd] 0x00 unsigned char [0xe] 0x00 unsigned char [0xf] 0xff 'ÿ' unsigned char [0x10] 0xdb 'Û' unsigned char [0x11] 0x00 unsigned char [0x12] 0x43 'C' unsigned char [0x13] 0x00 unsigned char [0x14] 0x03 '␃' unsigned char [0x15] 0x02 '␂' unsigned char [0x16] 0x02 '␂' unsigned char [0x17] 0x03 '␃' unsigned char [0x18] 0x02 '␂' unsigned char [0x19] 0x02 '␂' unsigned char [0x1a] 0x03 '␃' unsigned char [0x1b] 0x03 '␃' unsigned char [0x1c] 0x02 '␂' unsigned char [0x1d] 0x03 '␃' unsigned char


#2

A JPEG file starts by 0xFF 0xD8 (or 0xFF 0xDB if there is an exif information somewhere).

So, try to read it starting by position 0xF in your example, it should read.


#3

Hey what are you using to extract the ID3? I’m using TagLib have you seen it? I haven’t tried to get the album art yet though. Any experiences with it?


#4

@X-Ryl669: Tried it, but I get an exception thrown by the JPEGImageFormat reader code. Maybe the JPEG is corrupt, but VLC Media Player shows the pic correctly (I wrote Windows Explorer, that’s not correct, Windows Explorer doesn’t show any thumbnail for the file).
@TheVinn: I’m using Windows’ own functions. Don’t want to use any LGPL’ed code if possible.


#5

TagLib is dual-licensed, also available under the Mozilla Public License, which only requires you to publish changes to TagLib if any.


#6

Post :shock: very good


#7

Don’t bother, I’m using TagLib to read out the Image now and it works.