mdls – lists the metadata attributes for the specified file
This command has been around for twenty years and Im slightly surprised I haven't come across it before. Every day is a learning point.
Using mdls to find lat long data in an image file
Metadata List – % mdls filename and look at the man pages % man mdls to find out more.
Screenshot of the mdls command in macOS Ventura
Seems like it would be very handy in a script. I cant find any more information about it or its origins. Drop me a note if you know more about where this command originated.
Leakage of your personal information via metadata
The trouble with images, is that they can contain a lot of personally identifiable data. You shoud be very careful indeed about where you share images without sanitising or removing the metatada.
Image file can contain the precise location of the picture, and the name and even the email address of the recipient, as well as the date and time and direction that the picture was taken in. These are potentially very personal items of data that you might not wish to share. Most social media photo uploads strip meta data but you cannot be absolutely sure and should be very careful about exposing this data randomly on the Internet!
{ToC}
Alarming personally identifiable metadata in image files you might be sharing
Deleting personally identifiable metadata in image files you might be sharing
See Also:
Alarming personally identifiable metadata in image files you might be sharing
Here's an example (sanitised with dummy data from a real picture). Try putting the Lat Long into google maps. Its ok its not mine!
Important! – If you are not horrified by this then you should be
% mdls IMG_1234.HEIC
_kMDItemDisplayNameWithExtensions = "IMG_1234.HEIC"
kMDItemAcquisitionMake = "Apple"
kMDItemAcquisitionModel = "iPhone 11 "
kMDItemAestheticScore = 0.3942871
kMDItemAltitude = 169.27124614707178
kMDItemAperture = 1.69599381283836
kMDItemBitsPerSample = 24
kMDItemColorSpace = "RGB"
kMDItemContentCreationDate = 2023-07-24 16:33:21 +0000
kMDItemContentCreationDate_Ranking = 2023-07-24 00:00:00 +0000
kMDItemContentModificationDate = 2023-07-24 16:33:21 +0000
kMDItemContentRating = 0
kMDItemContentType = "public.heic"
kMDItemContentTypeTree = (
"public.heic",
"public.heif-standard",
"public.image",
"public.data",
"public.item",
"public.content"
)
kMDItemCreator = "16.5.1"
kMDItemDateAdded = 2023-07-24 16:33:57 +0000
kMDItemDisplayName = "IMG_1234.HEIC"
kMDItemDocumentIdentifier = 0
kMDItemEXIFVersion = "2.3.2"
kMDItemExposureMode = 0
kMDItemExposureProgram = 2
kMDItemExposureTimeSeconds = 0.02941176470588235
kMDItemFlashOnOff = 0
kMDItemFNumber = 1.8
kMDItemFocalLength = 4.25
kMDItemFocalLength35mm = 26
kMDItemFSContentChangeDate = 2023-07-24 16:33:28 +0000
kMDItemFSCreationDate = 2023-07-24 16:33:28 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = (null)
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = (null)
kMDItemFSLabel = 0
kMDItemFSName = "IMG_1234.HEIC"
kMDItemFSNodeCount = (null)
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 502
kMDItemFSSize = 1335183
kMDItemFSTypeCode = ""
kMDItemGPSDestBearing = 128.4571992110454
kMDItemHasAlphaChannel = 0
kMDItemImageDirection = 45.4571992110454
kMDItemInterestingDate_Ranking = 2023-07-24 00:00:00 +0000
kMDItemISOSpeed = 500
kMDItemKind = "HEIF Image"
kMDItemLatitude = 51.503368
kMDItemLogicalSize = 1335183
kMDItemLongitude = --0.127721
kMDItemMediaAnalysisLastAttempt = 2023-07-24 17:28:49 +0000
kMDItemMeteringMode = 5
kMDItemOrientation = 0
kMDItemPhotosCharacterRecognitionAnalysisVersion = (null)
kMDItemPhotosSceneAnalysisVersion = (null)
kMDItemPhotosSceneClassificationConfidences = (null)
kMDItemPhotosSceneClassificationIdentifiers = (null)
kMDItemPhotosSceneClassificationLabels = (null)
kMDItemPhotosSceneClassificationSynonyms = (null)
kMDItemPhotosSceneClassificationSynonymsCounts = (null)
kMDItemPhysicalSize = 1335296
kMDItemPixelCount = 12192768
kMDItemPixelHeight = 3024
kMDItemPixelWidth = 4032
kMDItemProfileName = "Display P3"
kMDItemRedEyeOnOff = 0
kMDItemResolutionHeightDPI = 72
kMDItemResolutionWidthDPI = 72
kMDItemSpeed = 0.2421859436108752
kMDItemUserSharedReceivedDate = (
"2023-07-24 16:33:58 +0000"
)
kMDItemUserSharedReceivedRecipient = (
"Fred Bloggs"
)
kMDItemUserSharedReceivedRecipientHandle = (
"This email address is being protected from spambots. You need JavaScript enabled to view it. "
)
kMDItemUserSharedReceivedSender = (
"Fred Bloggs"
)
kMDItemUserSharedReceivedSenderHandle = (
"This email address is being protected from spambots. You need JavaScript enabled to view it. "
)
kMDItemUserSharedReceivedTransport = (
"com.apple.AirDrop"
)
kMDItemWhereFroms = (
"Fred Bloggs",
"11 Pro Max"
)
kMDItemWhiteBalance = 0
Deleting personally identifiable metadata in image files you might be sharing
mdls doesn't let you edit the data.
The easiest way to get rid of it is to open the image using preview, and create a new one from it.
Open the image
Select All (⌘ A)
Copy (⌘ C)
New from Clipboard (⌘ N)
Save (⌘ S)
Name the file
Check with 'Get Info' (⌘ I in Finder)
No personal metadata should exist in the new image.
See Also:
What can macOS Sonoma find in my images? – The Eclectic Light Company