Can a Caption be added to a Photo using Terminal?
Can a Caption be added to a Photo using Terminal?
You can make a difference in the Apple Support Community!
When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.
When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.
Can a Caption be added to a Photo using Terminal?
What is the end use for the image once the caption is added?
The EXIF spec supports Caption-Abstract, and ImageDescription. They can be applied to an image via:
exiftool -P -EXIF:ImageDescription="some text…" foo.jpg
exiftool -P -IPTC:Caption-Abstract="some text…" foo.jpg
In either case, the text is written into the IPTC and TIFF sections of the image metadata using the respective Caption-Abstract and Image Description keywords. The -P preserves the original creation date.
What is the end use for the image once the caption is added?
The EXIF spec supports Caption-Abstract, and ImageDescription. They can be applied to an image via:
exiftool -P -EXIF:ImageDescription="some text…" foo.jpg
exiftool -P -IPTC:Caption-Abstract="some text…" foo.jpg
In either case, the text is written into the IPTC and TIFF sections of the image metadata using the respective Caption-Abstract and Image Description keywords. The -P preserves the original creation date.
My point is that if you used just one of the two examples, the text will be assigned to two different metadata categories within the given image.
IPTC:
TIFF:
There may be other Metadata fields: 1)Exif, 2)JFIF, GPS, etc. in an image. You can see these categories segmented in the Preview Inspector. Also note, these text strings are only visible in a Finder Get Info panel, and not available in the Finder Preview options.
Spotlight can locate the image based on keywords derived from the MDLS kMDItemDescription:
kind:image description:arf
kind:image description:"arf woof"
And it appears that one can batch process this with a CSV from a post in the EXIF Forum.
Working as I need with -IPTC:Caption-Abstract so the following is just some observations:
When I use -EXIF:ImageDescription, and then import into Photos, the text is not showing up in Captions (it is shown in the file with exiftool -list, however)
Now, I'm using a long caption, so maybe there's some char limit in Photos (I'm downloading the Astronomy Picture of the day and adding their "Explanation…" as a Caption)
And here's what Preview info shows:
Some time ago, I wrote a Python/ObjC script that dumps the entire image metadata to a scrollable window. I copied part of Steve Jobs Stanford speech to the clipboard and then inserted that as a caption:
exiftool -P -IPTC:Caption-Abstract="$(pbpaste)" test.jpg
and my script displayed that content in its entirety in the IPTC section of that image metadata:
So, the data is there in the image, despite Apple either truncating or with-holding access to it. When I add this image to Apple's Photos on macOS 11.6.1, and then ask Photos to Get Info, it shows the same caption content as above in a scrollable section immediately above any keywords.
When I do the following on an jpg image with neither keyword in it, and is not already in Photos, and then follow up by adding it to Photos:
exiftool -P -EXIF:ImageDescription="$(pbpaste)" test.jpg
Both the IPTC and TIFF sections are now populated with the Job's speech text in the Caption-Abstract and ImageDescription keys respectively, and Photos displays this scrollable text in the Get Info window. I suspect that Photos is only dipping into IPTC:Caption-Abstract, and not TIFF:ImageDescription, but hard to tell since both get written in my command-line above.
Repeated the above on a TIFF image and though exiftool reported 1 file updated, when the image was added to Photos, there was no Caption shown, though the text was in the image's TIFF section's ImageDescription field.
I just took a jpg image I created here with ImageMagick that was not based on any photograph and only contained this information from an image on macOS 12.0.1:
I made a copy (C.jpg) and ran ExifTool on it:
exiftool -p -EXIF:ImageDescription="$(pbpaste)" C.jpg
This added a TIFF section with the ImageDescription key containing the pasted text, but no IPTC:Capture-Abstract key. Also, in Photos, there was no caption displayed, which pretty much narrows Photos to using the Capture-Abstract key when it is present in an IPTC section of the EXIF metadata.
Here is the results of the EXIF metadata after the above command on this image:
They were photo jpgs that already had an IPTC section in the EXIF metadata content. Non-photographic sourced images will not have this IPTC section where it must write the Capture-Abstract key. As to why EXIF tool redundantly writes both keys and their text content in different EXIF sections is a mystery to me.
I have a Canon EOS R5 RAW image that I ran the following on it with the Job's speech text, and the ImageDescription data was written correctly, according to ExifTool, but nothing appeared from my Python program, or in the Photos Caption field.
exiftool -P -EXIF:ImageDescription="$(pbpaste)" test.CR3
I looked at the EXIF standard for Caption-Abstract and ImageDescription keywords, and there is no apparent limit placed on the text length, though as you have shown, Apple's tools truncate for format convenience. I suspected this outcome.
VikingOSX wrote:
Some time ago, I wrote a Python/ObjC script that dumps the entire image metadata to a scrollable window. I copied part of Steve Jobs Stanford speech to the clipboard and then inserted that as a caption:
exiftool -P -IPTC:Caption-Abstract="$(pbpaste)" test.jpg
and my script displayed that content in its entirety in the IPTC section of that image metadata:
So, the data is there in the image, despite Apple either truncating or with-holding access to it. When I add this image to Apple's Photos on macOS 11.6.1, and then ask Photos to Get Info, it shows the same caption content as above in a scrollable section immediately above any keywords.
As I said, IPTC:Caption-Abstract works, it’s EXIF:ImageDescription that does not, (even though the ImageDescription tag is in the image as shown with exiftool -list)
Try your script with exiftool -P -EXIF:ImageDescription="some text…" foo.jpg and Photos will not display it.
Didn’t do that for me ( Monterey). The Preview file info I posted was on 2 separate jpg images downloaded from a web page, and using only -EXIF:ImageDescription did not have an IPTC section (see above).
exiftool (v12.36 ) does not update the IPTC tag for me when I use -EXIF:ImageDescription
Are you using an exiftool option that's not posted here?
Preview truncates, however, Photos does not display -EXIF:ImageDescription at all (even short text):
Working, thanks.
As either of the 2 examples you posted write into the IPTC and TIFF sections of the image metadata, is there any difference between these two methods, or is one preferable?
I would do both. I think he meant EXIF, not TIFF.
EXIF is the most "standard"
IPTC is used by the big boys, but not so generally
https://en.wikipedia.org/wiki/IPTC_Information_Interchange_Model
While either should work in my Shortcut, for some reason only -IPTC:Caption-Abstract is working, so I'll stick with that. (I'm using a very long caption, do maybe that is why)
Which confirms what I’ve been saying all along 🙂
(But how did you get EXIF:ImageDescription to add text to both the Description Tag and IPTC Tag in your previous Jobs Speech example.)
Can a Caption be added to a Photo using Terminal?