JPG file can't be opened?

I have a bunch of older .jpg files that I need to open. When I try to open them using Xojo, it says the file format is not supported. Double-clicking them in macOS gets me the message “The file could not be opened. It may be damaged or use a file format that Preview doesn’t recognize”. I’m running macOS Catalina.

I used GraphicConverter 11 to open them, it says they are RGB/8 files and successfully opens them. The one I am testing is 750w x 500h and is 1.5MB. It has a .jpg file extension.

I tried using OpenAsJPEGMBS, but it failed no matter whether AllowDamaged was true or false.

Any suggestions on how to open these files in Xojo? And once I have them open, is there a file format that is likely to continue to be supported into the future?

Thank you -

Are you sure those are not files with wrong file extension?

What does our JPEGImporterMBS class report via error event?

I agree with Christian. RGB8 is not JPG. If GraphicsConverter can open them, then I suggest you use it to convert them to actual JPG or PNG instead.

Sorry, the file extension is JPG, the files were all created with an older version of Xojo, exporting as JPG. Graphic Converter reports them as JPG (RGB/8). whatever that means.

I tried following the MBS example for JPEGImporter, but ji.InitJPEG fails.

Interestingly, if I open one of the files with Graphic Converter and then save it again as JPG, macOS Preview recognizes and opens it. FWIW, the original file is 551KB, after saving from Graphic Converter, the file is 90KB.

The problem is, I need my app to open these files, they are photos of lighting for hundreds of shows over the years.

Can you email me one to check?
Maybe it’s a different JPEG variant, we don’t support any longer.

I just emailed it to you.

I used JPG because at the time (1997 or a few years later), it was a very popular format…

got it.
It has a 128 byte header before the JPEG.
So use a binary steam, go to offset 128 and read the rest to pass to JPEG reading function.

Graphicsconverter comments it like this:

Processing JPEG-like data after unknown 128-byte header

Maybe some archiving software processed it?

1 Like

The Unarchiver.app unpacks it and provides the jpg inside.

That’s a great clue, it might have been zipped - though odd that the .jpg extension is preserved.

Thank you!

Let me just go on record here saying the value that Christian adds to the Xojo community is nothing short of amazing. Not only do I have no idea how he supports so many functions and classes (especially given Apple’s penchant for moving targets), but things like this thread show his willingness to go above and beyond the call of duty.

IMHO anyway.

Thank you Christian!

7 Likes

It’s not zip, but may be some other archive format.
But none our Archive classes support.

Thanks @Douglas_Handy for the compliments.

The file was created by RealBasic, I’ll try launching that and see what the circa 1988 source code does.

Thanks for your help, you really are a treasure!

It gets more interesting. The pictures were saved using JPEGExporterMBS, which is still supported. Back in 2015, they were opened using Picture.Open(f). It worked then, but not now. My suspicion is that the code in Picture.Open makes calls to macOS functions that aren’t available anymore - which would explain why the Preview app won’t open them, and probably why the corresponding MBS calls fail, too.

Can anyone recommend a file format that is likely to be supported for a long time? PNG? TIFF?

I don’t think JPEG has changed. If they worked back then then its more likely that there was bug somewhere in the encoder at the time or in the JPEG library under the hood (which technically is the encoder). Maybe even ending problem.

But regardless of the reason then generic file formats like this do not go obsolete. So from that point of view then it would not matter if its JPG, TIFF or PNG their all very established formats that are not going anywhere. When looking at lifetime of data then its more proprietary formats that you need to worry about, like I had some documents in Page Maker back then, which is just lost data today.

1 Like

Is probably not going anywhere soon because of it’s flexibility.

Just keep them and remove the extra header.

Yep, stripped the extra bytes from the beginning fixed it. Thank you!

It would be a format that just adds headers at the beginning of the file and preserve the entire file otherwise; can this be called an “archive”?