Improved improved GPS removal

October 22nd, 2010

I updated my jpeg geotag-removal script to recurse subdirectories. With that came the requirement to filter out irelevant files (not jpeg, no EXIF information). Below is the new script. I hope you find it useful:
# Will remove non-essential EXIF from a jpeg while retaining Date/Time value.
# Use it to remove GPS information from pictures I want to put on the internet.
# Created Wed Aug 11 18:43:03 PDT 2010
# For handling spaces. See:
IFS=$(echo -en "\n\b")
for img in $@; do
    file_type=`file -b $img`
    if [ -d "$img" ]; then
        echo "$img" is a directory - recursing
    $0 "$img/*"
    elif [ $file_type == "JPEG image data" ]; then
        # Grab the original date/time
        DT=`jhead "$img"|grep 'Date/Time'`
        # If the date information started out
        # blank, trying to tack it back on
        # will result in an error
        if [ "$DT" == '' ]; then
            # Current format: " Date/Time : yyyy:mm:dd hh:mm:ss"
            # jhead requires: yyyy:mm:dd-hh:mm:ss
            # Strip non-essential information
            jhead -purejpg "$img"
            # Put the date/time back
            jhead -mkexif -ts$DT "$img"
        echo "$img" is not a JPG - ignoring $file_type

Tags: ,

Comments are closed.