Converting Unix executable photo files

If you have had photos become “Unix executable” format then do the following to convert them to jpeg:

Be sure that you have the files on a disk that is properly formatted for Mac and not for Windows.

Append .jpg to the file name

Open in Preview

In the File menu choose “Export to….”

In the export menu that opens enter the destination, change the file name if you wish, and MOST CRITICALLY be sure that it is saved in the jpeg format because this may not automatically happen.

The saved file then should behave like a normal .jpg

MacBook Air 13″, macOS 14.1

Posted on Dec 14, 2023 4:40 PM

Reply
Question marked as Top-ranking reply

Posted on Dec 15, 2023 7:30 AM

One can obtain a reasonable idea (before guessing) of what the UNIX Executable file format is by its byte signature as illustrated in a list of file signatures. One checks the file for its byte signature like so:


xxd -u -c8 -l8 -g1 filename
00000000: 89 50 4E 47 0D 0A 1A 0A  .PNG....

xxd -u -c8 -l8 -g1 filename
00000000: FF D8 FF E0 00 10 4A 46  ......JF (jpg)

xxd -u -c8 -l8 -g1 filename
00000000: 00 00 00 0C 6A 50 20 20  ....jP (jp2)

xxd -u -c8 -l8 -g1 filename
00000000: 4D 4D 00 2A 00 75 30 08  MM.*.u0. (tif)



18 replies
Question marked as Top-ranking reply

Dec 15, 2023 7:30 AM in response to beadydee

One can obtain a reasonable idea (before guessing) of what the UNIX Executable file format is by its byte signature as illustrated in a list of file signatures. One checks the file for its byte signature like so:


xxd -u -c8 -l8 -g1 filename
00000000: 89 50 4E 47 0D 0A 1A 0A  .PNG....

xxd -u -c8 -l8 -g1 filename
00000000: FF D8 FF E0 00 10 4A 46  ......JF (jpg)

xxd -u -c8 -l8 -g1 filename
00000000: 00 00 00 0C 6A 50 20 20  ....jP (jp2)

xxd -u -c8 -l8 -g1 filename
00000000: 4D 4D 00 2A 00 75 30 08  MM.*.u0. (tif)



Feb 11, 2024 7:29 AM in response to FibreMan_85_125

FibreMan_85_125 wrote:

Is there a batch process to restore the jpg file extension?


If all the files are using the same internal format (see above) and can be bulk-selected in a Finder search-and-rename, sure. (info)


Otherwise, writing a shell script that uses find (or maybe mdfind) and calls the file magic command for each file (see above) and processes and renames the files accordingly is very likely feasible.


While news to me, it seems the oft-useful exiftool has a mechanism for this, too: https://superuser.com/a/1125652


A few dozen files probably isn’t worth custom automation, though. Not past a Finder bulk rename, or exiftool, etc. Or just renaming the files manually.


Is there a way to prevent this from reoccuring?


This mess should not happen in general, but—given the varied potential causes discussed above, and given the surprising design and coding practices of some apps—is probably not possible to completely prevent this.


App developers have occasionally been botching basic file operations and variously violating common expectations and practices for aeons, too.


You can also ask the app developers to use libmagic or such as part of their file open validation, too.


Dec 15, 2023 7:12 AM in response to beadydee

Be sure that you have the files on a disk that is properly formatted for Mac and not for Windows.
Append .jpg to the file name
Open in Preview

That will normally only work if the file actually is a JPEG to start with. If it's a TIFF or other raster format and you add .jpg to the end, that won't make it a JPEG. It will still be a TIFF or other file type with an incorrect extension.


However, I did test this just now. Photoshop does exactly what you would expect, and can't figure out how to open a .tif I intentionally misnamed as a .jpg file.



Affinity Designer, the same thing. Also as expected since the file is not actually a .jpg.



However, Preview must have simply ignored the extension and figured out what file type is what by the header information, and opened it anyway.

Dec 15, 2023 6:57 AM in response to Keith Barkley

Keith Barkley wrote:

I thought it happened when the extension is stripped. Since the Mac no longer has creator codes, it has no way of knowing what kind of file it is, so it makes generically makes it a unix executable.


Yep. That’s one of the file name corruptions, yes. I’ve seen similar messes caused by various issues and file name and file system corruptions, by default app changes, by missing or deprecated apps (e.g. some old 32-bit photo app gets vaporized by a macOS upgrade), and by missing or renamed file types. There have been several app packages that did their own and creative things with their image file names, seemingly trying to keep the images tied to the vendor’s apps.

Dec 15, 2023 7:06 AM in response to MrHoffman

There have been several app packages that did their own and creative things with their image file names, seemingly trying to keep the images tied to the vendor’s apps.

That was an issue (of sorts) with EPS files back in the OS 9 and earlier world. Unlike Windows, where only one app could be associated with the .eps extension, no matter which app actually created it, at least the Mac had type and creator codes.


On all of them, the type was EPSF, but apps and Mac OS were still able to keep track of who owned which EPS by the creator. 8*** for Photoshop, ART5 for Illustrator, another for Quark XPress (which I can't recall right now). And so on.


But without a file extension, and the current Mac OS no longer paying attention to type/creator codes, the OS no longer knows what to do with them, so they just get tagged as a generic UNIX file.

Feb 11, 2024 7:59 AM in response to FibreMan_85_125

Along with MrHoffman's links, a while back I put together a tiny compiled AppleScript that will tell you what the Type and Creator codes are for a file.


https://www.macupdate.com/app/mac/62161/typecreator


Run that on any of these mislabeled Unix files and (if it has them) it will tell you what the file is. Such as, anything with 8*** as the creator is a Photoshop file. The type should then be readily apparent JPEG, TIFF, EPFS, etc.

Dec 15, 2023 7:17 AM in response to Kurt Lang

My reference to “creative” includes using no extension and a directory full of images, and includes apps that are using magic to identify files. Apple deprecated their own creator codes stuff a while back (older OSX, IIRC) but magic is still around (see man file), and app implementors will probably want to use the BSD magic version if implementing an app with magic. BSD rewrote and hardened their magic a while back. I’ve written various apps that auto-adapt to what gets opened, even if it is misnamed.

Feb 11, 2024 6:59 AM in response to MrHoffman

A few dozen .jpg files from ca. 2003 - 2004 have lost the file extension, but many others - older and newer -have not. They were screen captures, re-arranged and finesses by GraphicConverter. All remained on my main mac computer, though it and the OS were updated.


Last they were used was probably ~ 2018 when they worked fine, but being used sporadically, I don't know when that changed.


Two questions:


Is there a batch process to restore the jpg file extension?


and


Is there a way to prevent this from reoccuring?


Call me "an unidentified developer" 😉

Feb 11, 2024 10:01 AM in response to MrHoffman

MrHoffman wrote:
App developers have occasionally been botching basic file operations and variously violating common expectations and practices for aeons, too.

You can also ask the app developers to use libmagic or such as part of their file open validation, too.


There are reasons to not do this recognition, too. For some contexts, polyglot files — files that present as two (or more) different formats — can be a bit of a nightmare for some apps and for security. The oldest I’ve met (and one of many) was the so-called gifar file, which is both a gif image file and a Java jar file. Together. Websites might not mind somebody uploading a probably-harmless gif file, but probably don’t want somebody uploading a jar (executable) file.


Related:

https://github.com/ansemjo/truepolyglot

https://arxiv.org/abs/2203.07561


Ange Albertini has numerous clever polyglot file combinations, and has posters of common file formats, too. Apropos this discussion, here is the jpeg poster from that collection:


Feb 11, 2024 11:44 AM in response to MrHoffman

Messrs Hoffman and Lang; I appreciate your helpfulness!


Finder Rename tool worked perfectly... I think*. It's amazing how many things I either forgot or never knew as macOS evolved. Each release should have a study guide and quiz required to pass before being allowed to install.


*The files were in a Finder search window for 'unix', but they originated from several different folders. I wanted to check them to be sure they all worked, but after select all—right click—add '.jpg', they (of course) disappeared one by one. 😆


I'm not sure how to find them! A Finder search has nothing with changed date more recent than 2 days ago. Huh?


I appreciate your helpfulness in the manner you've learned and teach, but I prefer to stay out of the nuts and bolts. Thanks again!

Feb 11, 2024 12:01 PM in response to FibreMan_85_125

FibreMan_85_125 wrote:

I'm not sure how to find them! A Finder search has nothing with changed date more recent than 2 days ago. Huh?

I appreciate your helpfulness in the manner you've learned and teach, but I prefer to stay out of the nuts and bolts. Thanks again!


Yet you simultaneously ask another involves-the-nuts-and-bolts question. 😉🤔🤭😉


I’d expect Spotlight will catch up with the name change shortly.


Everybody’s favorite “mds” processes are undoubtedly now active and are updating the Spotlight database.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Converting Unix executable photo files

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.