
Trying to automatically set IPTC keywords for a large number of photos using Claude Code
Claude Code is a valuable tool for app development, but due to having "Code" in its name, it's often thought to be useful only for coding. However, in reality, it's an excellent tool that can be utilized for a wide range of purposes, such as novel writing and task automation.
In this article, I'll introduce a method for automatically registering IPTC keywords to photos. I hope this will be helpful for those struggling with organizing large numbers of photos.
Current State of Photo Management
I currently manage my photos using software called Eagle. While I previously used Adobe Lightroom when working at a design company, it felt somewhat excessive for personal use, so I've settled on Eagle now.
Eagle has a convenient feature where if you enable automatically add IPTC keywords as tags when adding images
in the settings, it will automatically import the IPTC keywords set in the images as tags when registering photos.
However, manually inputting IPTC keywords for a large number of photos is time-consuming. When you have hundreds or thousands of photos, this can require a significant amount of work time.
What Are IPTC Keywords?
IPTC keywords are part of the standard image metadata format established by the IPTC (International Press Telecommunications Council). This is information that can be embedded directly into photo files and is used to record keywords or tags that represent the content of the image.
It's similar to the Exif standard, but while Exif is primarily aimed at camera manufacturers and records shooting conditions, IPTC was developed for news organizations and is used to organize vast numbers of photographs.
This standard has been widely adopted in the field of photojournalism and is standardly supported by major photo management and editing software like Adobe Lightroom and Photoshop.
By utilizing IPTC keywords, you can quickly search for specific content among a large number of photos. It also enables systematic classification and organization by subject or shooting location, and since the information is embedded in the file itself, it won't be lost when the file is moved.
Traditionally, keywords had to be entered manually, but with the development of AI image recognition technology, this task can now be largely automated. In this article, I'll introduce the results of my attempt to automate IPTC keywords using Claude Code.
Manual IPTC Keyword Registration Using ExifTool
First, I'll introduce the basic method of manually registering IPTC keywords using ExifTool.
Installing ExifTool
ExifTool is a powerful command-line tool that can manipulate image metadata. It can be easily installed using Homebrew.
brew install exiftool
Basic Usage
To set location information:
exiftool -GPSLatitude=35.7107818 -GPSLongitude=139.7953126 -GPSLatitudeRef=N -GPSLongitudeRef=E image.jpg
To change the shooting date and time:
exiftool -DateTimeOriginal="2025:07:22 12:00:00" image.jpg
Setting Multiple IPTC Keywords
IPTC keywords can be set in a similar way. To set multiple keywords, specify -IPTC:Keywords
multiple times, and each keyword will be registered individually.
exiftool -IPTC:Keywords="landscape" -IPTC:Keywords+="mountain" -IPTC:Keywords+="nature" image.jpg
While this method allows for manual tag registration, it's not practical for large numbers of photos.
Photo Analysis and Automatic Tag Generation Using Claude Code
Now that we understand manual operations with ExifTool, let's tackle automation using Claude Code. After some trial and error, I found the following workflow to be most effective.### Directory Structure Preparation
First, create the following four folders in your working directory.
before
: Store photos before processingprogressing
: Temporarily store photos during processingafter
: Store photos after processing is completedskipped
: Store photos that could not be processed due to errors
Processing Rules for Claude Code (CLAUDE.md)
The following rule file defines the flow for safely processing images one by one and the criteria for setting IPTC tags. Particularly important points are:
- Stepwise file movement between the four directories
- Consistent tagging with English keywords
- Automatic skip function in case of errors
- Five category classifications including people, animals, food, etc.
Since the detailed instruction document (CLAUDE.md) is lengthy, it is published in the following Gist.
Processing Procedure
Processing with Claude Code follows these steps:
- Launch Claude Code in the working directory
- Load the CLAUDE.md file
- Instruct it to "process"
- Images in the
before
folder are automatically processed one by one
During processing, file movement between directories happens automatically, and if an error occurs, the relevant file is moved to the skipped
folder.
Processing Results
When processing is complete, tagged photos are saved in the after
directory. When checked with ExifTool, you get results like:
% exiftool -IPTC:Category -IPTC:ObjectName -IPTC:Keywords -IPTC:Caption-Abstract image.jpeg
Category : ANI
Object Name : Dog in carrier
Keywords : dog, chihuahua, pet carrier, small dog, outdoor, street, travel, pet transport
Caption-Abstract : Small dog in pet carrier bag on street
When importing these processed photos into Eagle, IPTC keywords are automatically recognized as tags, enabling search and classification.
Strictly speaking, it's a Chiweenie (mix of Chihuahua and Miniature Dachshund), but since only the head is visible, it's recognized as a chihuahua
.
Conclusion
By utilizing Claude Code, I was able to significantly automate the photo tagging process that was previously done manually. This method enables efficient metadata application even for hundreds or thousands of photos.
Claude Code is not just a coding tool but also a powerful agent for automating rule-based tasks. I feel it has potential for use in various operations beyond photo management.
If you're struggling with organizing large numbers of photos, please try this method. It should greatly improve your photo management efficiency.
Notes and Troubleshooting
API Usage Limitations
Image analysis with Claude Code seems to consume more API calls than coding tasks, reaching limits more quickly. With the Pro plan, you may reach the limit after processing about 50 images. If you need to process large quantities, it might be better to spread the work over multiple days.### Comparison with Other AI Tools
In this article, we conducted verification using Claude Code. Claude Code provides stable results for image analysis. Regarding other AI tools, they were not included in this verification study.
Supported File Formats
Verified to work with JPEG format image files. For PNG images, image analysis is possible, but there may be limitations when writing IPTC metadata with ExifTool.
Customization Possibilities
The CLAUDE.md
file can be customized according to your needs. By defining keyword systems specialized for specific industries or purposes, more specialized tagging can likely be achieved.