jhead is used to display and manipulate data contained in the Exif header of JPEG images from digital cameras. By default, jhead displays the more useful camera settings from the file in a user-friendly format.
jhead can also be used to manipulate some aspects of the image relating to JPEG and Exif headers, such as changing the internal timestamps, removing the thumbnail, or transferring Exif headers back into edited images after graphical editors deleted the Exif header. jhead can also be used to launch other programs, similar in style to the UNIX find command, but much simpler.
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 notpead 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.
The thumbnail is too low res to really use for anything.
This feature has an interesting 'relative path' option for specifying the thumbnail name. Whenever the name for file contains the characters '&i', jhead will substitute the original filename for this name. This allows creating a 'relative name' when doing a whole batch of files. For example, the 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). 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.
If a '-' is specified for the output file, the thumbnail is sent to stdout. (UNIX build only)
Like the '-st' option, this option uses a 'relative path', which is useful for doing a batch of photos at a time. For example, if you have a directory full of digital camera photos, before editing them, you could copy them into the subdirectory 'originals. Then edit them. After editing, you can put the original Exif headers back in to the whole directory of images at a time using the incantation: jhead -te originals/&i *.jpg
jhead -model S100 *.jpg
jhead -model S100 *.jpg
I use this option to restrict my JPEG recompensing to those images that came from my Cannon S100 digicam, (see the -cmd option).
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.
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.
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
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 them man pages. Note that some arguments to the strftime function (not listed here) produce strings with characters such as '/' and ':' that may not be valid as part of a filename on various systems.
This option changes all Date/time fileds in the exif header, including "DateTimeOriginal" (tag 0x9003) and "DateTimeDigitized" (tag 0x9004).
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
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
Year on camera was set to 2005 instead of 2004 for pictures taken in April
Default camera date is 2002:01:01, and date was reset on 2005:05:29 at 11:21 am
The Exif section of each file is read before running the command, and reinserted after the command finishes.
The specified command invoked separately for each JPEG that is processed, even if multiple files are specified (explicitly or by wild card). I use this option to process whole directory trees of JPEGs from my digital camera with jpegtran (Independent JPEG group) and ImageMagick's 'MOGRIFY' command without loosing the camera settings and other info stored in the Exif headers.
jpegtran is useful for lossless rotation, as well as for converting JPEGs to progressive JPEGs (also a lossless process, but results in typically 5% smaller files) I use mogrify for re-compressing the images I get from my Canon PowerShot S100 to 80% quality. The Canon JPEGs are either way too 'high quality' for the resolution, or are suboptimally encoded. Using mogrify to 80% produces no detectable loss in quality, with files about half the size.
Having a whole directory tree of photos from my S100, I run the following commands:
jhead -cmd mogrify -quality 80 &i -model S100 -r *.jpg
jhead -cmd jpegtran -progressive &i > &o -r *.jpg
The first command mogrifies all JPEGs in the tree that indicate that they are from a Cannon S100 in their Exif header to 80% quality at the same resolution. This is a 'lossy' process, so I only run it on files that are from the Canon, and only run it once. The next command then takes a JPEGs and converts them to progressive JPEGs. The result is the same images, with no discernible differences, stored in half the space. This only produces substantial savings on some cameras, such as the Canon S100. The newer S110 and S300 cameras are smarter about how they compress JPEG images, so re-mogrifying them may not give you any savings unless you crank the quality way down. However, turning them into progressive JPEG images is a lossless process that typically makes image files 5% smaller.
Keeping the Exif header information is important to me, as I like to check things like the shutter speed for some of my photos, and my HTML index generating program uses the Exif tags to display the JPEG images in order of taking.
Modifying of Exif header data is very limited, as 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, causing jhead to incorrectly miscalculate the sensor width and 35mm equivalent focal length. Jhead usually gets blamed for this bug, but it is in fact a camera bug, and jhead can't do much about it, and I'm not about to add camera bug specific hacks to it.
Send bug reports to mwandel at sentex dot net.