Till Anders hemsida Software
exifcleaner
exifcleaner will make Exif image files smaller by removing both any MakerNote section and any blank sections in the files.

Do not use this program. Use ExifTool by Phil Harvey instead!

Since I wrote this in 2004 and 2005 things have changed, and there now are much better tools available. I just keep this online for reference proposes, and if someone wants to see an early implementation of EXIF manipulation code. It has severe endian problems, and probably won't work on little-endian computers, so be very careful!

Using
  exiftool -PreviewImage= filename solved my problem.
You can check the names of the tags you want to remove with
  exiftool -s filename

Most digital still cameras save the pictures in the Exif file format. Exif is an extension to the JPEG file format, that makes it possible to store metadata about the picture, like the date and time the picture was taken and all the settings that the camera used. Some data fields are standardized, like aperture value, shutter time, focal length, whether the flash fired etc, but it also is possible for the camera maker to store values that are not part of the standard in a special "MakerNote" section.

The MakerNote sections from different cameras usually are between 400 and 1600 bytes in length, but some cameras have MakerNote sections in the 25,000 to 55,000 byte range. The larger MakerNotes often contain a whole JPEG picture for preview purposes, with lower resolution than the main image, but larger than the Exif integral thumbnail that is present too.

Also, files from some cameras have several kilobytes of blank sections (consisting of NUL characters) in them that are totally a waste of space.

When publishing digicam pictures on the web, downscaled to 500 or 600 pixels in width, and with image file sizes of 20 to 60 kbytes, it feels quite silly to keep a metadata section in the file that even may be larger than the image data itself. Large MakerNotes is of no use to the web page visitors and it just makes download times longer. At the same time it may be desired to keep the basic metadata such as timestamp, aperture, shutter time etc. This program will remove the MakerNote section and the blank sections from the files while keeping the rest of the Exif data, saving up to 55 kbytes depending on camera model.

Another reason for reducing the Exif data size is if you're using Apple iPhoto version 5 and experience that the program takes a long time both to start and to exit. Apparently, iPhoto 5 stores the Exif data, including the MakerNote and any blank sections, from all your photos into one single combined file called "Library.iPhoto". If you have say 6000 photos, and each has a 40KB MakerNote included, this makes "Library.iPhoto" expand to over 250MB. A solution to this is to strip the MakerNote before importing the images into iPhoto. Unfortunately it doesn't seem possible to erase the MakerNote after the image already is imported.

Note that while removing the blank sections doesn't make you lose anything, removing the MakerNotes actually has the effect that you lose some of your camera's proprietary metadata. The MakerNote section typically contains settings like digital zoom ratio, autofocus position, sharpening etc, that will be lost after processing. Use it only on copies of your files, for example when preparing them for web publishing.

Also note that this software may not work with your images. Each camera model stores the meta data and the image data a little bit differently, and the files may contain sections that the program can't handle. Photo editing software and camera-to-computer image transfer programs can also alter the structure of the files and insert unexpected data fields. Removal is done "in place" i.e. the original file will be replaced with the edited version. Back up important files first.

Download current version
WARNING!
exifcleaner has been reported to corrupt image files on some computers. I have not fully investigated when this happens, but I suspect it is an endianness issue. I have sucessfully run exifcleaner on big-endian platforms like MacOSX on PowerPC and Solaris on SPARC, but have had image files thrashed on a little-endian computer (Linux on x86). Only use exifcleaner on copies of your files.
Installation
Copy the file to a suitable directory, for example /usr/local/bin or somewhere in your own home directory. On some systems, it may be needed to rename it with a .pl extension, too.

Change the first line of the program to point to your own copy of Perl. /usr/local/bin/perl is common, and so is /usr/bin/perl (you probably can find out where your machine has it by typing whereis perl or which perl

To give the program execute permissions, type chmod 755 exifcleaner

Usage
The program is run from the command line in a Unix/Linux shell, the Terminal in MacOS X or similar.

exifcleaner [options] files
exifcleaner -r [options] dirs

options are:
-p
Preserves the filesystem time stamp. The edited files has the same creation dates as the old files.
-v
Just view the files without removing anything. The program presents a list of how much would be saved if the program was run without the -v flag.
files
A file name or a list of file names. The usual shell wildcards are supported.
-r
Recursively scan directories and subdirectories in the argument list.
dirs
A directory name or a list of directory names. The usual shell wildcards are supported.
Tested cameras
Canon EOS 10D.JPG1474 bytes removed.
Canon EOS 300D1464 bytes removed.
Canon Digital IXUS689 bytes removed.
Canon Digital IXUS 4001193 bytes removed.
Canon Digital IXUS i1315 bytes removed.
Canon Digital IXUS v771 bytes removed.
Minolta DiMAGE Z149293 bytes removed.
Nikon D7026396 bytes removed.
Nikon D10025017 bytes removed.
Olympus Camedia C-2020 Z3276 bytes removed.
Olympus Camedia C-5060 WZ7979 bytes removed.
Olympus Camedia C-60 Z7191 bytes removed.
Olympus Camedia D-3071668 bytes removed.
Pentax *ist D55317 bytes removed.
Pentax Optio MX449172 bytes removed.
Pentax Optio S27902 bytes removed.
Pentax Optio WPi40k to 50k bytes removed.
SonyEricsson K75030 bytes removed.
Sony DSC-P431578 bytes removed.
Sony DSC-U1020--45 bytes removed.
Sony DSC-U2019 bytes removed.
Sony DSC-U301588 bytes removed.
Version history
  • 2.1.0 (September 7, 2005)
    Added recursive scan of subdirectories after suggestion from Avi Flax.
  • 2.0.1 (September 2, 2005)
    Made the program skip files with Exif header but no Exif SubIFD.
  • 2.0.0 (September 2, 2005) Renamed to exifcleaner
    Major rewrite to deal with files with blank sections and non-consecutive data fields.
  • 1.0.0 (September 7, 2004) First stable release.
    Made the program skip files with MakerNote and InterOperability SubIFD in the reverse order, instead of crashing.
  • 0.9.2 (August 11, 2004)
    Added new -v flag to just examine files without modifying them.
  • 0.9.1 (August 2, 2004)
    Fixed coding error that made the thumbnail image unreadable (forgot to update the JpegIFOffset value).
  • 0.9.0 (July 31, 2004)
    First public release, under the name rmmn.
Possible future development
There are currently no plans to develop this program further, except for if someone reports a serious bug.

A "known issue" is that the program won't deal well with files that have more SubIFD:s than the ones that I've encountered so far. It handles IFD0 and IFD1, the Exif SubIFD (of course) and the InterOperability SubIFD, and it discards the whole MakerNote regardless of what it contains. If a file should contain more SubIFD:s, for instance one with GPS data or linked audio, the program would discard them too -- but leave the offset unalteted, possibly leading to malfunction in a Exif reader that tried to read those data fields. If files with GPS data would become common, I'll consider making a new version to deal with them.

One other possible future development would be to analyse the MakerNote and try to keep any metadata settings in it while discarding the big JPEG:s that are the real problem. Some MakerNotes have SubIFD:s in them too, and those could be kept, but since the MakerNote differs between each camera model and there aren't any official documentation for them, that would be a hard thing to do in a sufficently general manner.

A line of development that lies outside of the intended use of this porgram, but may be worth mentioning, is to not only copy the Exif data fields but to insert new values. Since all Exif data fields are read into memory and then written back to the new file, it would be possible to alter the contents of some or all of the data fields at will, or to create new data fields that the original lacked. It would also be possible to use the part of the program that writes the Exif data to disk in a new program that adds an Exif structure to JPEG files that don't have any metadata at all to begin with.

System requirements
  • Perl (successfully tested with version 5.6.1).
  • JPEG images from a digital camera.
  • A big-endian computer (e.g. MacOSX on PowerPC or Solaris on SPARC). I have not tested this fully, but exifcleaner will probably not work on little-endian computers (e.g. Linux or MacOSX on Intel x86).