LinuxCommandLibrary

jhead

Manipulate JPEG image headers

TLDR

Show all EXIF data

$ jhead [path/to/image.jpg]
copy

Set the file's date and time to the EXIF create date (file creation date will be changed)
$ jhead -ft [path/to/image.jpg]
copy

Set the EXIF time to the file's date and time (EXIF data will be changed)
$ jhead -dsft [path/to/image.jpg]
copy

Rename all JPEG files based on the EXIF create date to YYYY_MM_DD-HH_MM_SS.jpg
$ jhead -n%Y_%m_%d-%H_%M_%S *.jpg
copy

Rotate losslessly all JPEG images by 90, 180 or 270 based on the EXIF orientation tag
$ jhead -autorot *.jpg
copy

Update all EXIF timestamps (Format: +- hour:minute:seconds) (example: forgot to change the camera's time zone - removing 1 hour from timestamps)
$ jhead -ta-1:00:00 *.jpg
copy

Remove all EXIF data (including thumbnails)
$ jhead -purejpg [path/to/image.jpg]
copy

SYNOPSIS

jhead [options] [file ...]

PARAMETERS

-de
    Delete the entire EXIF header from the image.

-autorot
    Losslessly auto-rotate JPEG images based on their EXIF orientation tag. This physically rotates the image data without recompression, preserving quality.

-ft
    Set the file modification date to the EXIF date/time. Useful for correcting file system timestamps.

-P
    Preserve the original file modification time when writing changes back to the file. By default, modification time is updated.

-st <date-time>
    Set all image timestamps (EXIF and file modification) to the specified date and time. Format: YYYY:MM:DD-HH:MM:SS.

-ts
    Show the timestamp for the image (EXIF date/time).

-rkt
    Remove the EXIF thumbnail from the header. This can reduce file size slightly.

-rt
    Remove all EXIF tags except for the orientation tag. Useful for privacy or reducing metadata clutter.

-dt
    Delete the JPEG comment field from the image.

-mkfile
    Create an empty EXIF header if one is missing from the image.

-n<fmt>
    Rename files based on their EXIF date/time. The format string <fmt> supports specifiers like %%Y (year), %%m (month), %%d (day), %%H (hour), %%M (minute), %%S (second).

-te <target-dir>
    Specify a target directory where renamed files should be moved. Used in conjunction with -n.

-v
    Enable verbose output, showing more details about operations.

-q
    Enable quiet output, suppressing most messages.

-h
    Display a help message and exit.

DESCRIPTION

jhead is a command-line utility designed for interacting with EXIF (Exchangeable Image File Format) data embedded within JPEG image files. It allows users to read, modify, and delete EXIF information, which includes details like capture date and time, camera model, exposure settings, GPS coordinates, and image orientation.

Beyond simply displaying metadata, jhead can perform useful operations such as losslessly rotating JPEG images based on their EXIF orientation tag, renaming files according to the capture date, or adjusting timestamps. It's particularly useful for photographers and image organizers who need to manage large collections of digital photos and ensure metadata accuracy or consistency. Its simplicity and command-line interface make it suitable for scripting and batch processing.

CAVEATS

jhead operates directly on JPEG files and, like any direct file manipulation tool, carries a risk of data loss or corruption if misused or in case of unexpected file issues. Always back up important files before performing extensive modifications.

While excellent for EXIF, it does not offer comprehensive support for other metadata standards like XMP or IPTC, for which tools like exiftool are more suitable.

Lossless rotation with -autorot is guaranteed only if image dimensions are multiples of 8 or 16 (depending on chroma subsampling). Otherwise, the image may be recompressed, leading to generational loss.

LOSSLESS ROTATION CAPABILITY

One of jhead's standout features is its ability to perform true lossless JPEG rotation. Unlike recompression, which degrades image quality, jhead manipulates the JPEG header and image data blocks directly, preserving the original image quality. This is particularly valuable for correcting image orientation from cameras without losing detail.

BATCH PROCESSING FOR PHOTO ORGANIZATION

Due to its command-line nature, jhead is highly effective for batch processing. It can be easily integrated into shell scripts or used with commands like find and xargs to automate tasks such as renaming entire directories of photos based on their capture dates, correcting timestamps, or stripping unnecessary metadata from large collections.

HISTORY

jhead was created by Matthias W. Neeracher, with its development starting around the late 1990s/early 2000s. It emerged as digital cameras became commonplace and the need for a simple, command-line tool to manage EXIF data in JPEG files grew. It filled a niche for lightweight, efficient batch operations like renaming files by capture date and performing lossless rotations, making it a valuable utility for photographers and system administrators before more comprehensive cross-format metadata tools became widely available.

SEE ALSO

Copied to clipboard