EXIF info in JPEG images?


#1

Hi,
It seems to me that Juce does not recognize jpeg files if they contain EXIF (camera) data?

I think the issue is this function:

[code]bool JPEGImageFormat::canUnderstand (InputStream& in)
{
const int bytesNeeded = 10;
char header [bytesNeeded];

    return (in.read (header, bytesNeeded) == bytesNeeded)
            && header[6] == 'J'
            && header[7] == 'F'
            && header[8] == 'I'
            && header[9] == 'F';
}

[/code]
JPG files containing EXIF data would fail this test.

Any way to work around this?
[/code]


#2

Interesting… I guess it might just be a case of tweaking the function to accept EXIF files too (assuming that jpeglib can actually cope with those files). I’ll have a go of that when I get a moment…


#3

Thanks Jules!
I’ll try to look into this myself and let you know if I find anything.


#4

Jules,
The problem seems to be with the JUCE jpeg test.
libjpeg works fine.

Here’s a fix.
In file ImageFileFormat.cpp, change to the code below. You may also want to test the first file word to be 0xFFD8 (SOI) , for extra safety.
I did not add this as I wanted to keep the changes to a minimum.

bool canUnderstand (InputStream& in)
    {
        const int bytesNeeded = 10;
        char header [bytesNeeded];

        if (in.read (header, bytesNeeded) != bytesNeeded)
			return false;
		
		return 	(	header[6] == 'J'
					&& header[7] == 'F'
					&& header[8] == 'I'
					&& header[9] == 'F') 
				
				|| 
				(	header[6] == 'E'
                && header[7] == 'x'
                && header[8] == 'i'
                && header[9] == 'f')
				;
    }

#5