jhead は JPEGファイルのEXIF情報やサムネイル画像を操作するツール。
Exif Jpeg header manipulation tool

以下、Debian GNU/Linux etch でのマニュアルとヘルプのドキュメント。

$ jhead -h の結果


$ jhead -h
Jhead is a program for manipulating settings and thumnails in Exif jpeg headers
used by most Digital Cameras.  v2.6 Matthias Wandel, April 29 2006.
http://www.sentex.net/~mwandel/jhead
 
Usage: jhead [options] files
Where:
 files       path/filenames with or without wildcards
[options] are:
 
GENERAL METADATA:
  -te <name> Transfer exif header from another image file <name>
             Uses same name mangling as '-st' option
  -dc        Delete comment field (as left by progs like Photoshop & Compupic)
  -de        Strip Exif section (smaller JPEG file, but lose digicam info)
  -du        Delete non image sections except for Exif and comment sections
  -purejpg   Strip all unnecessary data from jpeg (combines -dc -de and -du)
  -ce        Edit comment field.  Uses environment variable 'editor' to
             determine which editor to use.  If editor not set, uses VI
             under Unix and notepad with windows
  -cs <name> Save comment section to a file
  -ci <name> Insert comment section from a file.  -cs and -ci use same naming
             scheme as used by the -st option
  -cl string Insert literal comment string
 
DATE / TIME MANIPULATION:
  -ft        Set file modification time to Exif time.
  -n[format-string]
             Rename files according to date.  Uses exif date if present, file
             date otherwise.  If the optional format-string is not supplied,
             the format is mmdd-hhmmss.  If a format-string is given, it is
             is passed to the 'strftime' function for formatting
             In addition to strftime format codes:
             '%f' as part of the string will include the original file name
             '%i' will include a sequence number, starting from 1. You can
             You can specify '%03i' for example to get leading zeros.
             This feature is useful for ordering files from multiple digicams to
             sequence of taking.  Only renames files whose names are mostly
             numerical (as assigned by digicam)
             The '.jpg' is automatically added to the end of the name.  If the
             destination name already exists, a letter or digit is added to
             the end of the name to make it unique.
  -nf[format-string]
             Same as -n, but rename regardless of original name
  -a         (Windows only) Rename files with same name but different extension
             Use together with -n to rename .AVI files from exif in .THM files
             for example
  -ta<+|->h[:mm[:ss]]
             Adjust time by h:mm backwards or forwards.  Useful when having
             taken pictures with the wrong time set on the camera, such as when
             traveling across time zones or DST changes. Dates can be adjusted
             by offsetting by 24 hours or more.  For large date adjustments,
             use the -da option
  -da<date>-<date>
             Adjust date by large amounts.  This is used to fix photos from
             cameras where the date got set back to the default camera date
             by accident or battery removal.
             To deal with different months and years having different numbers of
             days, a simple date-month-year offset would result in unexpected
             results.  Instead, the difference is specified as desired date
             minus original date.  Date is specified as yyyy:mmm:dd or as date
             and time in the format yyyy:mmm:dd/hh:mm:ss
  -ts<time>  Set the Exif internal time to <time>.  <time> is in the format
             yyyy:mm:dd-hh:mm:ss
 
THUMBNAIL MANIPULATION:
  -dt        Remove exif integral thumbnails.   Typically trims 10k
  -st <name> Save Exif thumbnail, if there is one, in file <name>
             If output file name contains the substring "&i" then the
             image file name is substitute for the &i.  Note that quotes around
             the argument are required for the '&' to be passed to the program.
             An output name of '-' causes thumbnail to be written to stdout
  -rt <name> Replace Exif thumbnail.  Can only be done with headers that
             already contain a thumbnail.
  -rgt[size] Regnerate exif thumbnail.  Only works if image already
             contains a thumbail.  size specifies maximum height or width of
             thumbnail.  Relies on 'mogrify' programs to be on path
 
ROTATION TAG MANIPULATION:
  -autorot   Invoke jpegtran to rotate images according to Exif orientation tag
             Note: Windows users must get jpegtran for this to work
  -norot     Zero out the rotation tag.  This to avoid some browsers from
             rotating the image again after you rotated it but neglected to
             clear the rotation tag
 
OUTPUT VERBOSITY CONTROL:
  -h         help (this text)
  -v         even more verbose output
  -V         Show jhead version
  -exifmap   Dump header bytes, annotate.  Pipe thru sort for better viewing
  -se        Supress error messages relating to corrupt exif header structure
  -c         concise output
  -nofinfo   Don't show file info (name/size/date)
 
FILE MATCHING AND SELECTION:
  -model model
             Only process files from digicam containing model substring in
             camera model description
  -exonly    Skip all files that don't have an exif header (skip all jpegs that
             were not created by digicam)
  -cmd command
             Apply 'command' to every file, then re-insert exif and command
             sections into the image. &i will be substituted for the input file
             name, and &o (if &o is used). Use quotes around the command string
             This is most useful in conjunction with the free ImageMagick tool.
             For example, with my Canon S100, which suboptimally compresses
             jpegs I can specify
                jhead -cmd "mogrify -quality 80 &i" *.jpg
             to re-compress a lot of images using ImageMagick to half the size,
             and no visible loss of quality while keeping the exif header
             Another invocation I like to use is jpegtran (hard to find for
             windows).  I type:
                jhead -cmd "jpegtran -progressive &i &o" *.jpg
             to convert jpegs to progressive jpegs (Unix jpegtran syntax
             differs slightly)
  -orp       Only operate on 'portrait' aspect ratio images
  -orl       Only operate on 'landscape' aspect ratio images

$ man jhead の結果


JHEAD(1)                                                              JHEAD(1)
 
 
 
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 for-
       mat.
 
       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.
 
OPTIONS
       -autorot
              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 distribu-
              tions.  For windows, you need to get a copy of it.  After  rota-
              tion, the orientation tag of the Exif header is set to '1' (nor-
              mal 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 use-
              ful with newer Canon cameras, that set the orientation tag auto-
              matically using a gravity sensor.
 
       -norot Clears the rotation field in the Exif  header  without  altering
              the image.  Useful if the images were previously rotated without
              clearing the Exif rotation tag, as some image browsers will auto
              rotate images when the rotation tag is set.
 
       -dt    Delete  thumbnails from the Exif header, but leave the interest-
              ing 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 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.
 
       -rt file
              Replace thumbnails from the Exif header with the content of file
              file.  This only works if the exif  header  already  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.  Relies on  'mogrify'  program  (from
              ImageMagick)  to  regenerate  the thumbnail.  This only works if
              the image already contains a thumbnail.
 
       -de    Delete the Exif header entirely.  This leaves  comments  in  the
              comment section intact.
 
       -dc    Delete  comment  field from the JPEG header.  Note that the com-
              ment is not part of the Exif header.
 
       -du    Delete sections of jpeg that are not Exif, not comment, and oth-
              erwise  not contributing 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 combintion of the -de -dc and -du options.
 
       -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 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.
 
       -cs file
              Save comment section to a file
 
       -ci file
              Replace comment with text from file
 
       -cl string
              Replace comment with specified string from command line file
 
       -st file
              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 anything.
 
              This feature has an interesting 'relative path' option for spec-
              ifying the thumbnail name.  Whenever the name for file  contains
              the  characters   '&i', jhead will substitute the original file-
              name 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 direc-
              tory  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)
 
       -te file
              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 editing the photos.
 
              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 'origi-
              nals.  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
 
       -h     Displays 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 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.
 
       -se    Suppress error messages relating to corrupt Exif  header  struc-
              ture.
 
       -V     Print version info and compilation date.
 
       -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).
 
       -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, the fol-
              lowing  command will list only images that are from an S100 cam-
              era:
 
              jhead -model S100 *.jpg
 
              jhead -model S100 *.jpg
 
              I use this option to restrict my  JPEG  rectification  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.  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.
 
       -n[format_string]
              This  option  causes files to be renamed using the date informa-
              tion 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.   Renaming  is  by  default
              restricted to files whose names consist largely of digits.  This
              effectively restricts renaming to files that  have  not  already
              been manually renamed, as the default sequential names from dig-
              ital cameras consist largely of digits.  Use the -nf  option  to
              force renaming of all files.
 
              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 strf-
              time 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  cam-
              era  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
 
              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 '/' and ':' that may not be valid as part of  a  filename  on
              various systems.
 
       -nf    Same as '-n' but renames files regardless of original file name.
 
       -ta<+|->[timediff]
              Adjust time stored in the Exif header by h:mm backwards or  for-
              wards.   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  changes  all  Date/time fileds in the exif header,
              including "DateTimeOriginal"  (tag  0x9003)  and  "DateTimeDigi-
              tized" (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  speci-
              fied 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 -da2005:03:01-2004: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.  This option only changes the "DateTimeOrigi-
              nal" (tar 0x9003) field, but leaves the "DateTimeDigitized" (tag
              0x9004)  field  alone.   Time  must be specified as: yyyy:mm:dd-
              hh:mm:ss
 
       -ft    Sets the file's system time stamp to what is stored in the  Exif
              header.
 
       -cmd   Executes  the  specified  command  on  each Jepg file to be pro-
              cessed.
 
              The Exif section of each file is read before  running  the  com-
              mand, 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  con-
              verting JPEGs to progressive JPEGs (also a lossless process, but
              results in typically 5% smaller files) I use mogrify for re-com-
              pressing  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.
 
              Example use:
 
              Having  a whole directory tree 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 dis-
              cernible differences, stored in half the space.  This only  pro-
              duces  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 pho-
              tos, and my HTML index generating program uses the Exif tags  to
              display the JPEG images in order of taking.
 
SEE ALSO
       jpegtran(1), mogrify(1), rdjpgcom(1), wrjpgcom(1)
 
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 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 res-
       olution  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.
 
 
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 2.6                        29 April 2006                        JHEAD(1)

tags: zlashdot Zura Exif Jpeg Linux Tool

Posted by NI-Lab. (@nilab)