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?
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.
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.
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.