1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
|
<html>
<span style="font-family: helvetica,arial,sans-serif;">
<h3>Jhead is a command line driven program for manipulating the non-image parts of Exif flavour
JPEG files that most digital cameras produce.</h3><p>
Windows / Mac users: Jhead has <b>no Graphical User Interface</b>. Clicking on it with the mouse from Windows
or Mac OS-X won't do anything for you - you have to <b>use it from the Command prompt</b>
<h3>Jhead v2.97 program Features</h3>
<ul>
<li>Extracting camera settings from Exif image files
<li>Able to set and/or adjust the Exif time field
<li>Manipulation (extract, replace, regenerate) of Exif integral thumbnails
<li>Transplant Exif image header from one JPEG to another
<li>Edit JPEG comment fields
<li>Automatically rotate images upright (using jpegtran) according to "orientation" tag.
<li>Manage running programs on large batches of Jpegs and restoring Exif header
information afterwards.
<li>Display embedded GPS info (if present)
</ul>
<h3>General metadata options</h3>
<table cellpadding=5>
<tr valign=top><td><b>-te <name>
<td>
Transplant Exif header from image <name> into specified image. This option is
useful if you like to edit the photos but still want the Exif header on your photos.
As most photo editing programs will wipe out the Exif header, this option can be used
to re-transplant them back in after editing the photos.
<br>
This feature has an interesting 'relative path' option for specifying the thumbnail name.
Whenever the <name> 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:
<ul>jhead -te "originals\&i" *.jpg</ul>
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.
<tr valign=top><td><b>-dc
<td>Delete comment field from the JPEG header. Note that the comment
is not part of the Exif header.
<tr valign=top><td><b>-de
<td>Delete the Exif header entirely. This leaves other sections (IPTC, XMP, comment) intact
<tr valign=top><td><b>-di
<td>Delete IPTC section (if present). Leaves other sections intact.
<tr valign=top><td><b>-dx
<td>Delete XMP section (if present). Leaves other sections intact.
<tr valign=top><td><b>-du
<td>Delete any sections that jhead doesn't know about. Leaves Exif, XMP, IPTC and comment
sections intact.
<tr valign=top><td><b>-purejpg
<td>Delete all JPEG sections that aren't necessary for rendering the image. Strips any
metadata that various applications may have left in the image. A combination of
the -de -dc and -du options.
<tr valign=top><td><b>-mkexif
<td>Creates minimal Exif header. Exif header contains date/time, and empty thumbnail
fields only. Date/time set to file time by default.
use with -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.
<tr valign=top><td><b>-ce
<td>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).
<br>
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.
<tr valign=top><td><b>-cs <name>
<td>Save comment section to a file
<tr valign=top><td><b>-ci <name>
<td>Replace comment with text from file.
<tr valign=top><td><b>-cl <comment>
<td>Replace comment with comment from command line.
</table>
<h3>Date / Time manipulation options</h3>
<table cellpadding=5>
<tr valign=top><td><b>-ft
<td>Sets the file's system time stamp to what is stored in the Exif header.
<tr valign=top><td><b>-dsft
<td>Sets the Exif timestamp to the file's timestamp. Requires an Exif header to pre-exist.
Use -mkexif option to create one if needed.
<tr valign=top><td><b>-n[<fmt-string>]
<td>This option causes files to be renamed and/or moved according to 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.
<p>
If the name includes '/' or '\' (under windows), this is interpreted as a new path for
the file. If the new path does not exist, the path will be created.
<p>
If the [fmt-string] is omitted, the file will be renamed to MMDD-HHMMSS.
<br>
If a [fmt-string] is provided, the fmt-string will be passed to the
strftime function for formatting. In addition, if the format string contains '%f', this will
substitute the original name of the file (minus extension).
<br>
A sequence number may also be included by including '%i' in the format string. Leading
zeros can be specified. '%03i' for example will pad the numbers to '001', '002'...
this works just like printf in C, but with '%i' instead of '%d'.
<br>
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.
<br>
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 when viewed with some sort of viewer like Xnview or AcdSee, and
sorted by name. Or you could use the -ft option and view the images sorted by date.
Typically, one of the carera's date will be set not quite right, in which case you may have
to use the -ta or -da options on those files first.
<p>
<b>Some of the more useful arguments for strftime are:</b>
<table>
<tr><td>%d   </td><td>Day of month as decimal number (01 31)
<tr><td>%H</td><td>Hour in 24-hour format (00 23)
<tr><td>%j</td><td>Day of year as decimal number (001 366)
<tr><td>%m</td><td>Month as decimal number (01 12)
<tr><td>%M</td><td>Minute as decimal number (00 59)
<tr><td>%S</td><td>Second as decimal number (00 59)
<tr><td>%U</td><td>Week of year as decimal number, with Sunday as first day of week (00 53)
<tr><td>%w</td><td>Weekday as decimal number (0 6; Sunday is 0)
<tr><td>%y</td><td>Year without century, as decimal number (00 99)
<tr><td>%Y</td><td>Year with century, as decimal number
</table>
<p>
Example:<br>
    jhead -n%Y%m%d-%H%M%S *.jpg<p>
This will rename files matched by *.jpg according to YYYYMMDD-HHMMSS
<p>
Note to Windows batch file users: '%' is used to deliminate macros in Windows batch files. You must
use %% to get one % passed to the program. So from a batch file, you would have to write "jhead -n%%Y%%m%%d-%%H%%M%%S *.jpg"
<p>
For a full listing of strftime arguments, look up the strftime function. 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.
<tr valign=top><td><b>-a
<td>(Windows only option). Rename files with the same name but different extension as well.
This is useful for renaming .AVI files based on Exif file in .THM, or to rename sound annotation
files or raw files with jpeg files. Use together with '-n' option.
<tr valign=top><td><b>-ta<timediff>
<td>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.
This option uses the time from the "DateTimeOriginal" (tag 0x9003) field, but sets
all the time fields in the Exif header to the new value.
<p>
Examples:<br>
Adjust time one hour forward (you would use this after you forgot to set daylight savings
time on the digicam)<br>
<ul>jhead -ta+1:00 *.jpg</ul>
Adjust time back by 23 seconds (you would use this to get the timestamps from two digicams
in sync after you found that they didn't quite align)
<ul>jhead -ta-0:00:23 *.jpg</ul>
Adjust time forward by 2 days and 1 hour (49 hours)
<ul>jhead -ta+49 *.jpg</ul>
<tr valign=top><td><b>-da<date>-<date>
<td>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. This feature is best for adjusting dates on pictures taken
over a large range of dates. For pictures all taken the same date, the "-ds" option
is often easier to use.
<p>
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
<p>
Examples:<br>
Year on camera was set to 2004 instead of 2005 for pictures taken in April
<ul>jhead -da2005:03:01-2004:03:01</ul>
Default camera date is 2002:01:01, and date was reset on 2005:05:29 at 11:21 am
<ul>jhead -da2005:05:29/11:21-2002:01:01</ul>
<tr valign=top><td><b>-ts<date-time>
<td>Sets the date and time stored in the Exif header to what is specified on the command line.
This option changes all the date fields in the Exif header.
Time must be specified as:<br>
<font face=courier>     yyyy:mm:dd-hh:mm:ss</font><p>
<tr valign=top><td><b>-ds<date-time>
<td>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:<br>
<font face=courier>     yyyy:mm:dd, yyyy:mm, or yyyy</font><p>
</table>
<h3>Thumbnail manipulation options</h3>
<table cellpadding=5>
<tr valign=top><td><b>-dt
<td>Delete thumbnails from the Exif header, but leave the
interesting parts intact. This option truncates the thumbnail from the Exif header, provided
that the thumbnail is the last part of the Exif header (which so far as I know is always the case).
Exif headers have a built-in thumbnail, which is typically 240x160 and 10k in size.
This thumbnail is used by digital cameras. Windows XP, as well
as various photo viewing software may also use this thumbnail if present, but work just fine
if it isn't.
<tr valign=top><td><b>-st <name>
<td>Save the built in thumbnail from Jpegs that came from a digital camera. The thumbnail lives
inside the Exif header, and is a very low-res JPEG image. Note that making
any changes to a photo, except for with some programs, generally wipes out the Exif header
and with it the thumbnail.
<br>
I implemented this option because I kept getting asked about having such an option.
I don't consider the
built in thumbnails to be all that useful - too low res. However, now you can see for
yourself. I always generate my thumbnails using ImageMagick (see end of this page).
<br>
Like the '-te' option, this feature has the 'relative path' option for specifying the
thumbnail name.
Whenever the <name> 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:
<ul>jhead -st "thumbnails\&i" *.jpg</ul>
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 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.
<p>
If a '-' is specified for the output file, the thumbnail is sent to stdout. (UNIX build only)
<tr valign=top><td><b>-rt <name>
<td>Replace thumbnails from the Exif header.
This only works if the Exif header already contains an Exif header a thumbnail.
<tr valign=top><td><b>-rgt[size]
<td>Regnerate Exif thumbnail.
'size' specifies maximum height or width of thumbnail.
I added this option because I had a lot of images that I had rotated with various tools that don't
update the Exif header. But newer image browsers such as XnView make use of the Exif thumbnail,
and so the thumbnails would be different from the image itself. Note that the rotation tag also
needed to be cleared (-norot option).
<br>
Typically, only images that are shot in portrait orientation are afflicted with this. You can use
the -orp option to tell jhead to only operate on images that are upright.
<p>
This option relies on 'mogrify' program (from ImageMagick) to regenerate the thumbnail.
Linux users often already have this tool pre-installed. Windows users have to go and download it.
This option only works if the image already contains a thumbail.
</table>
<h3>Rotation tag manipulation</h3>
<table cellpadding=5>
<tr valign=top>
<td><b>-autorot
<td>
Using the 'Orientation' tag of the Exif header, rotate the image so that it is upright.
The program 'jpegtran' is used to perform the rotation. This program is present in most
Linux distributions. For windows, you need to get a copy of it.
After rotation, the orientation tag of the Exif header is set to '1' (normal orientation).
The Exif thumbnail is also rotated. Other fields of the Exif header,
including dimensions are untouched, but the JPEG height/width are adjusted.<br>
This feature is especially useful with newer digital cameras, which set the orientation
field in the Exif header automatically using a built in orientation sensor in the camera.
<tr valign=top>
<td><b>-norot
<td>
Clears the Exif header rotation tag without altering the image.
You may find that your images have rotation tags in them from your camera, but you already
rotated them with some lossless tool without clearing the rotation tag.
Now your friendly browser rotates the images on you again because the image rotation
tag still indicates the image should be rotated. Use this option to fix this problem.
You may also want to regenerate the thumbnail using the -rgt option.
</table>
<h3>Output verbosity control</h3>
<table cellpadding=5>
<tr valign=top><td><b>-h
<td>Displays summary of command line options.
<tr valign=top><td><b>-v
<td>Makes the program even more verbose than it already is. Like DOS programs, and unlike
UNIX programs, Jhead gives feedback as to what it is doing, even when nothing goes wrong.
Windows user that I am, when something doesn't give me feedback for 20 seconds, I assume
its crashed.
<tr valign=top><td><b>-q
<td>Makes the progran mot spit out messages on success - more like the "Silence is golden" Unix way. its crashed.
<tr valign=top><td><b>-V
<td>Print version info and compilation date.
<tr valign=top><td><b>-Exifmap
<td>Show a map of the bytes in the Exif header. Useful when analyzing strange Exif headers,
not of much use to non software developers.
<tr valign=top><td><b>-se
<td>Suppress error messages relating to corrupt Exif header structure.
<tr valign=top><td><b>-c
<td>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).
</table>
<h3>File matching and selection</h3>
<table cellpadding=5>
<tr valign=top><td><b>-model
<td>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, the following command will list only images that are from an S100 camera:
<p>
jhead -model S100 *.jpg<p>
<p>
I use this option to restrict my JPEG re-compressing to those images that came from my
Cannon S100 digicam, (see the -cmd option).
<tr valign=top>
<td><b>-exonly
<td>Skip all files that don't have an Exif header. This skips all files that did not
come directly from the digital camera, as most photo editing software does not
preserve the Exif header when saving pictures.
<tr valign=top><td><b>-cmd<command>
<td>Executes the specified command on each Jepg file to be processed.<p>
The Exif section of each file is read before running the command, and re-inserted
after the command finishes.
<p>
This is useful for using jhead's file globbing capability for processing a whole
directory tree of files.
<p>
It's also useful for restoring the exif header after operatiosn that wipe out
the Exif metadata. Most programs today however will keep the Exif metadata
intact, so this is less important than it used to be.
<tr valign=top><td><b>-orp -orl
<td>Operate only on images with portrait (-orp) or landscape (-orl) aspect ratio.<br>
Please note that this is solely based on jpeg width and height values. Some browsers may auto
rotate the image on displaying it based on the Exif orientation tag, so that images shot
in portrait mode are displayed as portrait. However, the image itself may not be stored in
portrait orientation.
The -autorot and -norot options are useful for dealing with rotation issues.
<tr valign=top><td><b>-r
<td>The recursive feature of version 1.0 never worked to my satisfaction, and I replaced it
with my recursive file globbing code in the Windows version. See below.
</table>
<h3>Bugs and Shortcomings</h3>
<ul>
After jhead runs a program to rotate or resize an image, the image dimensions and thumbnail
in the Exif header are not adjusted.
<p>
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 the most part, Exif
can only modify pre-existing fixed-length fields in the header.
<p>
Most 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. The same 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.
</ul>
<h3>Name globbing and recursive directories under Windows</h3>
<ul>
Name globbing means matching wildcard patterns to actual file names. If you know what this
term means, you are probably annoyed at how programs on Windows typically handle this.
The Win32 version of this program goes beyond the pattern matching that Windows provides,
and allows you to specify fancy UNIX-like patterns such as:
<p>
<font size = 2 face="courier">  jhead c:\pix\199*\*\*.jpg</font>
<p>
This program goes one step beyond beyond that in that "**" as a path component means any
level of subdirectories. The invocation
<p>
<font size = 2 face="courier">  jhead c:\**\*.jpg</font>
<p>
will find ALL Jpegs files on the c: drive, including those in the root directory.
The <font size = 2 face="courier">**</font>
only works if it is the only part of that path component. For example, the path
<font size = 2 face="courier">'c:\a**\*.jpg'</font>
will not recurse.
The <font size = 2 face="courier">'**'</font>
recursive expansion is ONLY supported on the Windows version. The code is in the module 'myglob.c',
if you want to reuse it (I certainly intend to reuse that code for other applications).
Under UNIX, the shell's wildcard expansion is
pretty decent already, and dealing with the convoluted nature of some UNIX file layouts,
doing better would have been much more of a challenge.
</ul>
<h3>Programs I use with Jhead</h3>
<b>ImageMagick</b><br>
<ul>
I use the MOGIRIFY command from ImageMagick to do batch conversions and re-compresses of images.
If you use Linux, you probably already have ImageMagick on your system (just type 'mogrify' at the
command prompt to see if you have it). For Windows users, you have to download it from:
<a href="http://www.imagemagick.org"> http://www.imagemagick.org</a><p>
Image Magick is one of those programs that preserves comment and Exif headers, although older
versions do not.
</ul>
<b>JPEGTRAN</b><br>
<ul>
If you use Linux you probably also already have this program. For windows, it's hard to find a
pre-built binary on the web. The <a href="http://www.ijg.org"> Independent JPEG
Group</a>'s website only has the source code.<p>
There's a fancier version, with pre-built Windows binaries and a lossless cropping feature added at:
<a href="http://sylvana.net/jpegcrop"> http://sylvana.net/jpegcrop</a>.
</ul>
<b>XnView</b><br>
<ul>
<a href="http://www.xnview.com">XnView</a> is an excellent, small, fast, and free graphical image browser.
It makes use of jpeg thumbnails for the thumbnail view. On account of Xnview, I added
options to fix or regenerate the thumbnails to jhead, so that I could regenerate the thumbnails
for images where the thumbnail had gotten out of sync with the image.
<br>
Mac and Linux versions of XnView are also available.
</ul>
<b>wrjpgcom / rdjpgcom</b><br>
<ul>
You can use these programs to write and extract COM markers from JPEG images respectively. Although I always
use my jhead program for this feature, the wrjpgcom and rdjpgcom programs are extremely simple and very
suitable for use with perl or shell scripts to process lots of images. These programs are part of most
Linux distributions as part of the libjpg package (along with jpegtran)
</ul>
<p><br>
Jhead homeage: <a href="http://www.sentex.net/~mwandel/jhead">http://www.sentex.net/~mwandel/jhead</a><br>
Last Updated: Jan 30 2013<p>
|