JHEAD(1)

πŸ“¦
version 3.08 Β· 2 versions
, in arch rolling, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– JHEAD(1) β€” General Commands Manual πŸ’–

okay bestie, buckle UP, we're doing jhead today πŸŽ€


✨ NAME ✨

jhead β€” Digicam JPEG Exif header manipulation tool πŸ‘‘


🌸 SYNOPSIS 🌸

jhead [ options ] [ file...  ]

πŸ’… DESCRIPTION πŸ’…

so jhead is your girl for looking at and messing with all the data chillin' inside the Exif header of JPEG images from digital cameras. by default β€” like, zero options, just vibes β€” jhead shows you the more useful camera settings from the file in a user-friendly format. it's giving "here's what your camera was thinking" πŸ“Έ

jhead can also manipulate some aspects of the image relating to JPEG and Exif headers, like changing the internal timestamps, removing the thumbnail, or transferring Exif headers back into edited images after graphical editors deleted the Exif header. and she can also launch other programs, similar in style to the UNIX find command, but much simpler. lowkey iconic behaviour, ngl πŸ¦‹


πŸŽ€ GENERAL METADATA OPTIONS πŸŽ€

  • -te file β€” transplant the Exif header from a JPEG (one that has an Exif header) in file into the image that is being manipulated. this is the move when you love to edit your photos but still want the Exif header on them. most photo editing programs will just wipe out the Exif header (rude πŸ’€), so this option can be used to re-copy them back from original copies after editing the photos.
this feature has an interesting 'relative path' option for specifying the thumbnail name. whenever the <name> contains the characters &i, it will substitute the original filename for this name. this allows creating a jhead 'relative name' when doing a whole batch of files. for example, the incantation:
jhead -te originals/&i *.jpg

would transfer the exif header for each .jpg file in the originals directory by the same name. both Win32 and most Unix shells treat the & character in a special way, so you have to put quotes around that command line option for the & to even be passed to the program. no cap, the shell will snatch it otherwise πŸ™ˆ

  • -dc β€” delete the comment field from the JPEG header. note that the comment is not part of the Exif header. just so we're clear bestie ✨
  • -de β€” delete the Exif header entirely. leaves other metadata sections intact. full send on the exif, everything else stays 🫢
  • -di β€” delete the IPTC section, if present. leaves other metadata sections intact.
  • -dx β€” delete the XMP section, if present. leaves other metadata sections intact.
  • -du β€” delete sections of jpeg that are not Exif, not comment, and otherwise not contributing to the image either β€” like, data that photoshop might leave in the image. photoshop leftovers? not on our watch 🧹
  • -purejpg β€” delete all JPEG sections that aren't necessary for rendering the image. strips any metadata that various applications may have left in the image. this is a combination of the -de, -dc and -du options. the ultimate glow-up, she's got nothing to hide πŸ’…
  • -mkexif β€” creates a minimal exif header. the Exif header contains date/time, and empty thumbnail fields only. date/time is set to the file time by default. use with the -rgt option if you want the exif header to contain a thumbnail. note that exif header creation is very limited at this time, and no other fields can be added to the exif header this way. baby steps, she's doing her best 😭
  • -ce β€” edit the JPEG header comment field (note, this comment field is outside the Exif structure and can be part of Exif and non Exif style JPEG images).

a temporary file containing the comment is created and a text editor is launched to edit the file. the editor is specified in the EDITOR environment variable. if none is specified, notepad or vi are used under Windows and Unix respectively. after the editor exits, the data is transferred back into the image, and the temporary file deleted. clean. tidy. no trace 🌈

  • -cs file β€” save comment section to a file
  • -ci file β€” replace comment with text from file
  • -cl string β€” replace comment with the specified string from the command line

⏰ DATE / TIME MANIPULATION OPTIONS ⏰

  • -ft β€” sets the file's system time stamp to what is stored in the Exif header. syncing her up, bestie πŸ•
  • -dsft β€” sets the Exif timestamp to the file's timestamp. requires an Exif header to pre-exist. use the -mkexif option to create one if needed. no exif? no dice πŸ’€
  • -n[format_string] β€” this option causes files to be renamed and/or moved using the date information from the Exif header "DateTimeOriginal" field. if the file is not an Exif file, or the DateTimeOriginal does not contain a valid value, the file date is used. if the new name contains a /, this will be interpreted as a new path, and the file will be moved accordingly.

if the format_string is omitted, the file will be renamed to MMDD-HHMMSS. note that this scheme doesn't include the year (I never have photos from different years together anyway).

if a format_string is provided, it will be passed to the strftime function as the format string. in addition, if the format string contains %f, this will substitute the original name of the file (minus extension). %i will substitute a sequence number. leading zeros can be specified like with printf β€” i.e. %04i pads the number to 4 digits using leading zeros. obsessed with a well-padded sequence number fr fr πŸ”’

if the name includes /, this is interpreted as a new path for the file. if the new path does not exist, the path will be created. she'll build the whole directory tree for you, no questions asked πŸ‘‘

if the target name already exists, the name will be appended with "a", "b", "c", etc, unless the name ends with a letter, in which case it will be appended with "0", "1", "2", etc.

this feature is especially useful if more than one digital camera was used to take pictures of an event. by renaming them to a scheme according to date, they will automatically appear in order of taking in most directory listings and image browsers. alternatively, if your image browser supports listing by file time, you can use the -ft option to set the file time to the time the photo was taken. group-chat-photo-dump energy, but organised ✨

some of the more useful arguments for strftime are:

  • %H β€” Hour in 24-hour format (00 - 23)
  • %j β€” Day of year as decimal number (001 - 366)
  • %m β€” Month as decimal number (01 - 12)
  • %M β€” Minute as decimal number (00 - 59)
  • %S β€” Second as decimal number (00 - 59)
  • %w β€” Weekday as decimal number (0 - 6; Sunday is 0)
  • %y β€” Year without century, as decimal number (00 - 99)
  • %Y β€” Year with century, as decimal number

Example:

jhead -n%Y%m%d-%H%M%S *.jpg

this will rename files matched by *.jpg in the format YYYYMMDD-HHMMSS

for a full listing of strftime arguments, look up the strftime in the man pages. note that some arguments to the strftime function (not listed here) produce strings with characters such as : that may not be valid as part of a filename on some systems. careful bestie, some systems said no πŸ™ˆ

  • -ta<+|-><timediff> β€” adjust time stored in the Exif header by h:mm forwards or backwards. useful when having taken pictures with the wrong time set on the camera, such as after travelling across time zones, or when daylight savings time has changed. jet lag but for your metadata ✈️

Examples:

Add 1 hourand 5 minutes to the time

jhead -ta+1:05

Decrease time by one second:

jhead -ta-0:0:1

this option changes all Date/time fields in the exif header, including "DateTimeOriginal" (tag 0x9003) and "DateTimeDigitized" (tag 0x9004).

  • -da<newdate>-<olddate> β€” works like -ta, but for specifying large date offsets, to be used when fixing dates from cameras where the date was set incorrectly, such as having date and time reset by battery removal on some cameras. the classic "my camera forgot what year it is" situation 😭

because different months and years have different numbers of days in them, a simple offset for months, days, years would lead to unexpected results at times. the time offset is thus specified as a difference between two dates, so that jhead can figure out exactly how many days the timestamp needs to be adjusted by, including leap years and daylight savings time changes. the dates are specified as yyyy:mm:dd. for sub-day adjustments, a time of day can also be included, by specifying yyyy:nn:dd/hh:mm or yyyy:mm:dd/hh:mm:ss

Examples:

Year on camera was set to 2005 instead of 2004 for pictures taken in April

jhead -da2004:03:01-2005:03:01

Default camera date is 2002:01:01, and date was reset on 2005:05:29 at 11:21 am

jhead -da2005:05:29/11:21-2002:01:01
  • -ts β€” sets the time stored in the Exif header to what is specified on the command line. time must be specified as: yyyy:mm:dd-hh:mm:ss
  • -ds β€” sets the date stored in the Exif header to what is specified on the command line. can be used to set date, just year and month, or just year. date is specified as: yyyy:mm:dd, yyyy:mm, or yyyy

✨ THUMBNAIL MANIPULATION OPTIONS ✨

okay bestie, this is the part where we mess with the tiny lil thumbnail hiding inside the Exif header πŸ’…

  • -dt β€” deletes the thumbnail from the Exif header but leaves all the interesting parts intact πŸŽ€. It truncates the thumbnail from the Exif header, provided the thumbnail is the last part of the Exif header (which, so far as anyone knows, it literally always is). Exif headers have a built-in thumbnail that usually eats up around 10k of space, and it's the one digital cameras use. Windows XP may also use this thumbnail if it's present (but it doesn't need it, lowkey). The thumbnails are way too small to use even full screen on a digicam's LCD. The author has not encountered any adverse side effects from deleting thumbnails, even from the software that came with his old Olympus digicam. Still β€” use with caution 🫢.
  • -st file β€” saves the integral thumbnail to file ✨. The thumbnail lives inside the Exif header and is a very low-res JPEG image. Heads up: making any changes to a photo, except with some programs, generally wipes out the Exif header and the thumbnail with it 😭. And honestly the thumbnail is too low res to really use for very much.

This feature has a genuinely iconic 'relative path' option for naming the thumbnail: whenever the name for file contains the characters &i, jhead will substitute the original filename in for that name πŸ”₯. This lets you create a 'relative name' when doing a whole batch of files. For example, this incantation:

jhead -st thumbnails/&i *.jpg

would create a thumbnail for each .jpg file in the thumbnails directory by the same name (provided that the thumbnails directory exists, of course, obviously πŸ™ˆ). Both Win32 and UNIX shells treat the & character in a special way, so you have to put quotes around that command line option for the & to even be passed to the program, no cap.

And if you specify a - for the output file, the thumbnail gets sent to stdout. (UNIX build only) πŸ’œ

  • -rt β€” replaces thumbnails from the Exif header 🌸. This only works if the exif header already contains a thumbnail, and the thumbnail is at the end of the header (both are always the case if the photo came straight from a digital camera).
  • -rgt size β€” regenerates the exif thumbnail ✨. size specifies the maximum height or width of the thumbnail. It relies on the mogrify program (from ImageMagick) to do the regenerating. This only works if the image already contains a thumbnail.

πŸ”„ ROTATION OPTIONS πŸ”„

  • -autorot β€” using the 'Orientation' tag of the Exif header, this rotates the image so it's upright πŸ™Œ. The program jpegtran is used to perform the rotation, and it's present in most Linux distributions. For windows, you need to go get yourself a copy. After rotation, the orientation tag of the Exif header is set to 1 (normal orientation), and the thumbnail gets rotated too πŸŽ€. Other fields of the Exif header β€” including dimensions β€” are left untouched, but the JPEG height/width are adjusted. This feature is especially useful with newer Canon cameras that set the orientation tag automatically using a gravity sensor. main character energy fr.
  • -norot β€” clears the rotation field in the Exif header without altering the image πŸ’…. Super useful if the images were previously rotated without clearing the Exif rotation tag, because some image browsers will auto rotate images when the rotation tag is set. Sometimes thumbnails and rotation tags get very out of sync from manipulation with various tools 😭. To reset it all, use -norot together with -rgt to clear this out.

πŸ—£οΈ OUTPUT VERBOSITY CONTROL πŸ—£οΈ

  • -h β€” displays a summary of command line options.
  • -v β€” makes the program even more verbose than it already is πŸ“’. Like DOS programs, and unlike UNIX programs, Jhead gives feedback about what it's doing, even when nothing goes wrong. Windows user that I am: when something doesn't give me feedback for 20 seconds, I assume it's crashed πŸ’€.
  • -q β€” no output on success, more like Unix programs 🀫.
  • -V β€” print version info and compilation date.
  • -exifmap β€” show a map of the bytes in the exif header πŸ—ΊοΈ. Useful when analyzing strange exif headers, not of much use to non software developers.
  • -se β€” suppress error messages relating to corrupt Exif header structure πŸ™ˆ.
  • -c β€” concise output ✨. This causes picture info to be summarized on one line instead of several. Useful for grep-ing through images, as well as importing into spread sheets (data is space delimited with quotes as text qualifier).

🎯 FILE MATCHING OPTIONS 🎯

  • -model β€” restricts processing of files to those whose camera model, as indicated by the Exif image information, contains the substring specified in the argument after -model. For example, this command will list only images that are from an S100 camera:
jhead -model S100 *.jpg

The author uses this option to restrict his JPEG recompensing to only those images that came from his Canon S100 digicam (see the -cmd option πŸ‘€).

  • -exonly β€” skips all files that don't have an Exif header 🚫. Photos straight from a digital camera have an Exif header, whereas many photo manipulation tools discard the Exif header.
  • -proc β€” skips all but files matching process. Specifying -proc 0, for example, will only process files with baseline encoding. Specifying -proc 2 will only process files with progressive encoding. This option is useful when converting files to progressive jpegs using jpegtran, to skip those files already encoded as progressive jpegs. For example, the following command converts only files as baseline to progressive:
jhead -proc 0 -cmd "jpegtran -progressive -outfile &o &i" *.jpg
  • -cmd β€” executes the specified command on each JPEG file to be processed πŸ”₯.

The Exif section of each file is read before running the command, and reinserted after the command finishes.

The specified command is invoked separately for each JPEG that is processed, even if multiple files are specified (explicitly or by wild card).

Example use:

Having a whole directory of photos from his S100, the author runs the following commands:

jhead -cmd mogrify -quality 80 &i -model S100 *.jpg
jhead -cmd jpegtran -progressive &i > &o *.jpg

The first command mogrifies all JPEGs in the tree that indicate they are from a Canon S100 in their Exif header to 80% quality at the same resolution. This is a 'lossy' process ⚠️, so he only runs it on files that are from the Canon, and only runs it once. The next command then takes the JPEGs and converts them to progressive JPEGs. The result is the same images, with no discernible differences, stored in half the space. This produces substantial savings on some cameras πŸ‘‘


🌈 SEE ALSO 🌈

jpegtran(1), mogrify(1), rdjpgcom(1), wrjpgcom(1)


πŸ’– AUTHOR πŸ’–

Matthias Wandel


πŸ’€ BUGS πŸ’€

ok bestie, listen up, because these are real and you need to know them:

  • After jhead runs a program to rotate or resize an image, the image dimensions and thumbnail in the Exif header are not adjusted 😭.
  • Modifying of Exif header data is very limited, because Jhead internally only has a read only implementation of the file system contained in the Exif header. For example, there is no way to replace the thumbnail or edit the Exif comment in the Exif header. There is also no way to create minimal exif headers πŸ™ˆ.
  • Some Canon digital SLR cameras fail to adjust the effective sensor resolution when shooting at less than full resolution, which causes jhead to incorrectly miscalculate the sensor width and 35mm equivalent focal length 😡. The same thing can result from resizing photos with Photoshop, which will manipulate parts of the exif header. This is often reported as a bug in Jhead, but Jhead can't do much about incorrect data 🀷.
  • Send bug reports to matthias at woodgears dot ca πŸ“§

πŸ“œ COPYING PERMISSIONS πŸ“œ

Jhead is 'public domain'. You may freely copy jhead, and reuse part or all of its code in free or proprietary programs 🫢. He does however request that you do not post his e-mail address in ways that spam robots can harvest it πŸ™…


and that's the whole page bestie!! this was jhead version 3.06, dated 24 Mar 2021, and honestly? iconic. go forth and rotate your JPEGs the right way up πŸ’…βœ¨πŸ“Έ