0

Images downloaded from the web using Safari and macOS have information available from the Finder with Get Info. For example, "Where from" which can be the URL for the original image. Is that stored with the image or ?

exiftool image.jpg doesn't show the info.

The answer is in the two comments from @Gordon Davisson. Other responses were helpful also. For my purposes mdls is useful and xattr provides additional relevant information. Although I still don't quite understand where the info is stored I think it's safe to say it's not embedded in the file itself, but macOS and Windows can track the info.

Greg
  • 2,359
  • 5
  • 22
  • 35
  • 1
    It's in the extended attributes. Try `man xattr` in Terminal. – Mark Setchell Mar 29 '18 at 22:35
  • 2
    Thank you. `xattr -l image.jpg` displays the info. And the `Where from` is shown under `com.apple.metadata:kMDItemWhereFroms`. Is this stored in a separate file or database? I don't see any hidden files in the folder with the image file. – Greg Mar 29 '18 at 22:45
  • 1
    See [MacOS tags page](https://sno.phy.queensu.ca/~phil/exiftool/TagNames/MacOS.html) for info on how to extract this data with exiftool, as these tags are not extracted by default. – StarGeek Mar 29 '18 at 22:56
  • 1
    It's not in a separate file, I think it lives in the file's inode. If you do `ls -l` you'll see `@` after the permissions where it exists. – Mark Setchell Mar 29 '18 at 22:57
  • @MarkSetchell I'm not seeing any `@` with `ls -l` either for the folder or for the file. I'm in over my head here. Reading about inode in Wikepedia, I can't tell if it's in the file or stored somewhere with directory information which is what I think you're suggesting. ( I was asking for someone else because I requested a feature in an app that would need access to the `Where from`. ) – Greg Mar 29 '18 at 23:06
  • It's not part of the directory, the xattr info is attached to the file itself in roughly the same way that its access permissions and creation and modification dates are. – Gordon Davisson Mar 29 '18 at 23:38
  • @ Gordon Davisson. Would the info travel to a Windows machine? – Greg Mar 29 '18 at 23:49
  • 1
    It depends on how it's moved to a Windows machine. If you use the Finder to copy it over the network via SMB to an NTFS volume, xattrs will be stored as [NTFS alternate data streams](https://blogs.technet.microsoft.com/askcore/2013/03/24/alternate-data-streams-in-ntfs/); if you copy them to a FAT volume or something else that doesn't support rich metadata, they (and some other fancy metadata) will be encoded in [AppleDouble format](https://en.wikipedia.org/wiki/AppleSingle_and_AppleDouble_formats) and stored as a hidden flle with "._" at the front of the filename. It's complicated. – Gordon Davisson Mar 30 '18 at 06:17
  • @ Gordon Davisson. Your two answers pretty much tell me what I was looking for. I was asking for writers of a multi-platform program and had them if they could grab the "Where from" info. – Greg Mar 30 '18 at 16:45
  • @Greg please add your edited-in "answer" as an actual Answer! No reason to close. Others will find this Q/A helpful. – pkamb Mar 08 '20 at 05:00
  • @pkamb. How do I do that? – Greg Mar 08 '20 at 17:07
  • @Greg just press the "Answer Your Question" button below, then copy/paste your edited-in "answer" into the Answer box. Then edit it out of the question. That way people can clearly read/find the Answer and upvote it. – pkamb Mar 08 '20 at 20:11

3 Answers3

2

To access the values for a file's Finder metadata, use the mdls command in Terminal. This will list all the metadata attributes associated with the file:

mdls /path/to/file

Whereas this will retrieve the specific attribute:

mdls -name 'kMDItemWhereFroms' /path/to/file

or

mdls -name 'kMDItemWhereFroms' /path/to/file -raw

or

mdls -name 'kMDItemWhereFroms' /path/to/file -plist -

You can read more about the command on its man page

CJK
  • 5,732
  • 1
  • 8
  • 26
  • How do you delete it though? I can not get rid of the any kmd attribute. kMDItemAuthors is stuck there. what the hell? xattr -rd ... is not working .. – mjs Jan 23 '22 at 16:45
0

The answer is in the two comments from @Gordon Davisson. Other responses were helpful also. For my purposes mdls is useful and xattr provides additional relevant information. Although I still don't quite understand where the info is stored I think it's safe to say it's not embedded in the file itself, but macOS and Windows can track the info. PS: I'm posting this two years after the question in response to a request to do so.

Greg
  • 2,359
  • 5
  • 22
  • 35
0

To answer @mjs's question on how to delete, this is another way I found:

# List all attributes
xattr -lvr /path/to/file

# Delete the wherefrom tag
xattr -d com.apple.metadata:kMDItemWhereFroms /path/to/file

Reference

SydMK
  • 425
  • 4
  • 12