Script to fix problems in photos with Exif tag 0×0000

A number of cameras produce invalid or malformed Exif tags. One common problem that I’ve run into when receiving photos from other people is that the Exif data includes tag 0×0000, which is undefined and causes a number of programs to behave badly. (In particular, this crashes f-spot v5.0.3, which I use to organise my photo collection.)

Two cameras which I know have this problem are the Casio EX-Z1000 and the Canon PowerShot SX200 IS. (It’s possible that firmware updates have since fixed this, but the majority of people probably don’t update their cameras’ firmware.)

If you have a photo with Exif data that includes tag 0×0000, your software may spit out a message similar to the following before dying ungracefully:

Warning: IFD0 tag 0x0000 has invalid size...; truncating the data.
Warning: IFD0: Pointer to next IFD is out of bounds; ignored.
Warning: IFD0 tag 0x0000 has invalid Exif type 0; using 7 (undefined).

The above is the actual output from the exiv2 utility for manipulating Exif data when executed on a photo with this problem. (The “…” in the message above is typically a huge number, which may differ for each photo.)

Fortunately, the fix is very easy, using exiv2. Just run this command (replacing “filename” with the name of the actual file):

exiv2 -k -M"del Exif.Image.0x0000" filename

Because I use this command often enough, and when I do, I usually need to run it on a batch of photos at once, I’ve written a little bash script around it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
if [ "$1" = "" ]; then
    echo "Usage: fix_ex-z1000-photo [filename]"
else
    if [ -f "$1" ]; then
        for filename in "$@"
        do
            echo "Fixing \"$filename\""
            exiv2 -k -M"del Exif.Image.0x0000" "$filename"
        done
        exit 0
    else
        echo "ERROR: file \"$1\" does not exist."
        exit 1
    fi
fi

Just put the above in a file in “/usr/local/bin” (I called it “fix_ex-z1000-photo” but you can call it whatever you want), give it execute permission, and off you go. You can also run the script with wild cards, such as “fix_ex-z1000-photo mydir/*.jpg”.

– davinci 11772

If you like this post, you might also like:

  1. Converting DigiMemo files to Jarnal format

0 Responses to “Script to fix problems in photos with Exif tag 0×0000”


  • No Comments

Leave a Reply