Posts Tagged ‘remove GPS tags’

Improved improved GPS removal

Friday, 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:
#!/bin/bash
# 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:
# http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
 
for img in $@; do
 
    file_type=`file -b $img`
    file_type=${file_type:0:15}
 
    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
            continue;
        else
 
            # Current format: " Date/Time : yyyy:mm:dd hh:mm:ss"
            # jhead requires: yyyy:mm:dd-hh:mm:ss
            DT=${DT:15:25}-${DT:25}
 
            # Strip non-essential information
            jhead -purejpg "$img"
 
            # Put the date/time back
            jhead -mkexif -ts$DT "$img"
 
        fi
    else
        echo "$img" is not a JPG - ignoring $file_type
    fi
done

Improved GPS removal

Friday, August 13th, 2010

I recently posted about a way to remove the GPS information from pictures. I wrote a script that will retain the Date/Time information. It requires jhead.
#!/bin/bash
# Will remove non-essential EXIF from a jpeg
# while retaining Date/Time value. I 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:
# http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
 
for img in $@; do
    echo Working on "$img"
 
    # Grab the original date/time
    DT=`jhead "$img"|grep 'Date/Time'`
 
    # Current format: " Date/Time : yyyy:mm:dd hh:mm:ss"
    # jhead requires: yyyy:mm:dd-hh:mm:ss
    DT=${DT:15:25}-${DT:25}
 
    # Strip non-essential information
    jhead -purejpg "$img"
 
    # Put the date/time back
    jhead -mkexif -ts$DT "$img"
done

It accepts image files as arguments. You can pass as many or as few as you feel like. If you’re interested in keeping other non-essential exif data, you might want to look into the jhead argument “-te”.

Removing GPS data from an image

Wednesday, August 11th, 2010

I constantly forget how to remove the geotags from my pictures before I put them on the internet. Here’s an imperfect way to do so:
jhead -purejpg /path/to/image.jpg
Source

This will get rid of timestamps and other ancillary information that you may want to keep attached to the image. It seems like it would be pretty simple to write a script that uses jhead with no arguments to grab the Date/Time field, then run it again with -purejpg to remove all extraneous data, then run it a third time with the appropriate arguments to re-set the Date/Time field.