Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Can a Caption be added to a Photo using Terminal?

Can a Caption be added to a Photo using Terminal?

Posted on Nov 23, 2021 5:22 AM

Reply
Question marked as Best reply

Posted on Nov 23, 2021 6:01 AM

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.

15 replies
Question marked as Best reply

Nov 23, 2021 6:01 AM in response to Tony T1

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.

Nov 23, 2021 3:19 PM in response to Tony T1

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.

Nov 24, 2021 2:41 AM in response to VikingOSX

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:



Nov 24, 2021 7:06 AM in response to VikingOSX

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.

Nov 24, 2021 7:55 AM in response to Tony T1

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.


Nov 24, 2021 8:29 AM in response to Tony T1

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:


Nov 24, 2021 9:57 AM in response to Tony T1

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

Nov 24, 2021 7:27 AM in response to VikingOSX

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.

Nov 24, 2021 8:08 AM in response to VikingOSX


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?

Can a Caption be added to a Photo using Terminal?

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