Jhead Commands Every Photographer Should KnowJhead is a compact, command-line utility for reading, manipulating, and extracting metadata from JPEG files. It’s especially popular among photographers and script-savvy hobbyists because it provides fast, scriptable ways to inspect and modify EXIF information without launching a heavy GUI application. This article covers the most useful jhead commands and real-world workflows photographers will appreciate: viewing metadata, correcting timestamps, rotating files, stripping or extracting thumbnails, batch operations, and automating common tasks.
What jhead does (briefly)
Jhead focuses on JPEG files and EXIF metadata. Its typical uses include:
- Viewing EXIF data such as camera make, model, exposure settings, focal length, date/time, and GPS tags.
- Adjusting timestamps when a camera clock is wrong or when merging photos from multiple cameras.
- Rotating JPEGs using the EXIF orientation tag without modifying image pixels.
- Stripping metadata or thumbnails to reduce file size or protect privacy.
- Extracting thumbnails for quick previews or to recover lost images.
Installing jhead
On most Unix-like systems you can install jhead from your package manager:
- Debian/Ubuntu: sudo apt install jhead
- macOS (Homebrew): brew install jhead
- Windows: use WSL or download binaries from jhead’s site.
Viewing EXIF metadata
To view EXIF information for one or more JPEGs, run:
jhead image.jpg
For multiple files:
jhead *.jpg
This prints a concise summary that includes filename, file size, camera model, image resolution, date/time, and orientation. Use this as a quick way to audit a folder of images.
Getting full EXIF output
If you need more detailed information, use:
jhead -v image.jpg
This verbose output shows additional tags such as exposure time, aperture, ISO, focal length, and maker notes when available.
Adjusting date and time
A common real-world need is correcting camera clocks that were set incorrectly.
-
Set a specific date/time:
jhead -tsYYYY:MM:DD-hh:mm:ss image.jpg
Example:
jhead -ts2024:08:01-12:00:00 IMG_0001.jpg
-
Shift timestamps by a relative amount (useful when camera was in a different timezone or off by a fixed offset):
jhead -ta+hh:mm:ss *.jpg
Example: add 3 hours 30 minutes to all images:
jhead -ta+03:30:00 *.jpg
Negative offsets work too (e.g., -01:00:00).
Note: jhead changes the EXIF DateTimeOriginal and updates file modification time accordingly.
Copying timestamps between files
When you want to sync filesystem timestamps with EXIF timestamps:
jhead -ft image.jpg
This sets file modification time based on the EXIF timestamp. Useful when importing photos to a system that sorts by file date.
Rotate images based on EXIF orientation
Many cameras set an EXIF orientation flag rather than rotating pixels. To rotate images so the pixels match the orientation flag:
jhead -autorot *.jpg
This physically rotates the JPEG and clears the EXIF orientation flag so viewers that ignore the orientation still display correctly.
Remove thumbnails, comments, or all metadata
To reduce file size or remove identifying metadata:
-
Remove the embedded thumbnail:
jhead -st image.jpg
-
Remove comments:
jhead -dc image.jpg
-
Strip all EXIF metadata (be careful — this removes timestamps, GPS, and camera info):
jhead -purejpg image.jpg
Note: -purejpg makes the file a “pure” JPEG without EXIF; use backups if you need to preserve metadata.
Extracting thumbnails
To recover a thumbnail embedded in EXIF (handy for quick previews or recovering lost originals):
jhead -tf image.jpg
This writes the thumbnail to a file like image.jpg.thumb.jpg.
Writing GPS or other tags
jhead is mainly for reading and simple edits; it’s not a full EXIF editor for adding arbitrary tags. For GPS injection or complex edits, tools like ExifTool are more suitable. jhead excels at timestamp fixes, rotation, and lightweight metadata tasks.
Batch processing examples
-
Correct timestamps for all JPEGs in a folder by adding 2 hours:
jhead -ta+02:00:00 *.jpg
-
Rotate and then strip thumbnails for all images:
jhead -autorot *.jpg jhead -st *.jpg
-
Set filesystem time from EXIF for a batch:
jhead -ft *.jpg
Combine these in shell scripts for automated imports.
Integrating jhead in workflows
- In a shell import script: copy photos from SD card, run jhead -ta to correct timezone, jhead -autorot, then jhead -ft to normalize file dates.
- In image-processing pipelines: run jhead first to clean metadata and rotate, then pass files to image processors that expect correctly oriented pixels.
- For privacy-conscious sharing: run jhead -purejpg to remove metadata before uploading.
Troubleshooting and tips
- Always work on copies or use version control; some jhead operations are destructive.
- For complex edits (GPS, tag editing), prefer ExifTool.
- If an image doesn’t rotate as expected, check whether the EXIF orientation exists (jhead without -v may hide missing tags).
- jhead supports wildcards; be careful in directories mixing JPEGs and other file types.
Alternatives and when to use them
- ExifTool: full-featured, can write and edit nearly any tag. Use for GPS, batch tag rewriting, and advanced metadata tasks.
- jpegtran/mozcjpeg: for lossless JPEG transformations (rotation, optimization) without touching EXIF — combine with jhead for metadata tasks.
- GUI apps (Darktable, Lightroom): better for visual curation and non-technical users.
Example script (Linux/macOS) for importing and normalizing photos
#!/bin/bash SRC="/media/$USER/CARD/DCIM" DST="$HOME/Pictures/Import/$(date +%Y-%m-%d)" mkdir -p "$DST" rsync -av --progress "$SRC/" "$DST/" cd "$DST" # Correct timezone offset, rotate, set file times jhead -ta+02:00:00 *.jpg jhead -autorot *.jpg jhead -ft *.jpg
Conclusion
jhead remains a small but powerful tool for photographers who prefer command-line control over their JPEG metadata. Its speed, simplicity, and batch capabilities make it ideal for timestamp corrections, orientation fixes, thumbnail extraction, and lightweight privacy tasks. For any heavy-duty EXIF editing, pair jhead with more feature-rich tools like ExifTool; for most day-to-day fixes, jhead gets the job done quickly and reliably.