# jhead(1) - man - phpMan

[JHEAD(1)](https://www.chedong.com/phpMan.php/man/JHEAD/1/markdown)                               General Commands Manual                              [JHEAD(1)](https://www.chedong.com/phpMan.php/man/JHEAD/1/markdown)



## NAME
       jhead - Digicam JPEG Exif header manipulation tool

## SYNOPSIS
       **jhead** [ _options_ ] [ _file..._  ]


## DESCRIPTION
       **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.



## GENERAL METADATA OPTIONS
### -te
              Transplant  Exif  header from a JPEG (with Exif header) in _file_ into the image that is
              manipulated.  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-copy them back from original copies after  edit‐
              ing the photos.


              This  feature  has  an interesting 'relative path' option for specifying the thumbnail
              name.  Whenever the <name> contains the characters '&i', 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.


### -dc
              Exif header.

### -de

### -di

### -dx

### -du
              to the image either - such as data that photoshop might leave in the image.

### -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.  A combination  of  the
              -de -dc and -du options.

### -mkexif
              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.

### -ce
              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.

### -cs
              Save comment section to a _file_

### -ci
              Replace comment with text from _file_

### -cl
              Replace comment with specified string from command line


## DATE / TIME MANIPULATION OPTIONS
### -ft

### -dsft
              Use -mkexif option to create one if needed.

### -n
              This option causes files to be renamed and/ or mmoved 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 to‐
              gether anyway).

              If a _format_string_ is provided, it will be passed to the strftime function as the for‐
              mat 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 name includes '/', this is interpreted as a new path for the file.  If the  new
              path does not exist, the path will be created.

              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 auto‐
              matically  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

              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 them 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 sys‐
              tems.


### -ta<+|-><timediff>
              Adjust time stored in the Exif header by h:mm forwards or backwards.  Useful when hav‐
              ing  taken  pictures  with  the wrong time set on the camera, such as after travelling
              across time zones, or when daylight savings time has changed.

              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 "DateTimeOrigi‐
              nal" (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

              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
              Time must be specified as: _yyyy:mm:dd-hh:mm:ss_

### -ds
              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
### -dt
              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 typically occupies around 10k of space.  This
              thumbnail is used by digital cameras.  Windows XP  may  also  use  this  thumbnail  if
              present  (but  it  doesn't  need  it).   The thumbnails are too small to use even full
              screen on the digicam's LCD.  I have not  encountered  any  adverse  side  effects  of
              deleting  the thumbnails, even from the software provided with my old Olympus digicam.
              Use with caution.


### -st
              Save the integral thumbnail to _file_ 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.

              The thumbnail is too low res to really use for very much.

              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  do‐
              ing 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)


### -rt
              contains a thumbnail, and the thumbnail is at the end of the header (both  always  the
              case if the photo came from a digital camera)

### -rgt
              Regenerate  exif  thumbnail.   'size'  specifies maximum height or width of thumbnail.
              Relies on 'mogrify' program (from ImageMagick) to regenerate the thumbnail.  This only
              works if the image already contains a thumbnail.


## ROTATION OPTIONS
### -autorot
              Using  the  'Orientation'  tag  of the Exif header, rotate the image so that it is up‐
              right.  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 rota‐
              tion, the orientation tag of the Exif header is set to '1' (normal orientation).   The
              thumbnail  is  also rotated. Other fields of the Exif header, including dimensions are
              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.

### -norot
              the images were previously rotated without clearing the Exif rotation tag, as some im‐
              age browsers will auto rotate images when the rotation tag is set.  Sometimes,  thumb‐
              nails  and  rotation   tags  can  get  very out of sync from manipulation with various
              tools.  To reset it all use -norot with -rgt to clear this out.


## OUTPUT VERBOSITY CONTROL
### -h

### -v
              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  sec‐
              onds, I assume its crashed.

### -q

### -V -exifmap
              header. Useful when analyzing strange exif headers, not of much use  to  non  software
              developers.

### -se

### -c
              eral.  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
              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:

              _jhead_ _-model_ _S100_ _*.jpg_

              I  use  this option to restrict my JPEG recompensing to those images that came from my
              Canon S100 digicam, (see the -cmd option).

### -exonly
              Skip 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
              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

              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 mul‐
              tiple files are specified (explicitly or by wild card).

              Example use:

              Having a whole directory of photos from my S100, I run 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 that they are  from  a
              Canon  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 produces substantial savings on some cameras.


## SEE ALSO
       [**jpegtran**(1)](https://www.chedong.com/phpMan.php/man/jpegtran/1/markdown), [**mogrify**(1)](https://www.chedong.com/phpMan.php/man/mogrify/1/markdown), [**rdjpgcom**(1)](https://www.chedong.com/phpMan.php/man/rdjpgcom/1/markdown), [**wrjpgcom**(1)](https://www.chedong.com/phpMan.php/man/wrjpgcom/1/markdown)

## AUTHOR
       Matthias Wandel

## BUGS
       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, as Jhead internally only has a read  only  im‐
       plementation  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.  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.

       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.   I do however request that you do not post my  e-mail  address
       in ways that spam robots can harvest it.



jhead 3.06                                   24 Mar 2021                                    [JHEAD(1)](https://www.chedong.com/phpMan.php/man/JHEAD/1/markdown)
