Project

General

Profile

Gps Tag Latest Image - Remove GPS tag from other jpg

Added by Lee Griffiths over 4 years ago

Hi all

Looking for some advice to get a batch script running

Im using a program called PIWIGO to gather IP cam images - what I would like to do in PIWIGO is for the latest image only to show up on a map
The only way I can see to do that is to GPS tag a jpg as it comes in - that would make it show on a map - great

However when the next images comes in the script will do the same thing so you now have two images showing so I really need a way to strip off the gps tag of all other jpgs when the latest image come in and that is tagged

I dont know where to be begin really - can anyone offer up some advice

Thanks


Replies (4)

RE: Gps Tag Latest Image - Remove GPS tag from other jpg - Added by Robin Mills over 4 years ago

I'll help you. However, let me echo what I think you're asking. In a directory of images you want to strip GPS tags from every image, except the image with the youngest date/time. Is that correct?

You can determine the youngest file with this bash magic:

523 rmills@rmillsmbp:~/Pictures/2017/Norwich $ exiv2 -pe --grep DateTimeOriginal *.jpg | sort -k 5 | tail -1
DSC_3369.jpg          Exif.Photo.DateTimeOriginal                  Ascii      20  2017:03:28 19:21:36
524 rmills@rmillsmbp:~/Pictures/2017/Norwich $ 
And you can find all the images which have been geotagged with something like this:
526 rmills@rmillsmbp:~/Pictures/2017/Norwich $ exiv2 -pe --grep Exif.Image.GPSTag *.jpg
DSC_3301.jpg          Exif.Image.GPSTag                            Long        1  15236
DSC_3302.jpg          Exif.Image.GPSTag                            Long        1  15236
DSC_3303.jpg          Exif.Image.GPSTag                            Long        1  15236
...
You can obtain all the GPS tags in an image with something like this:
530 rmills@rmillsmbp:~/Pictures/2017/Norwich $ exiv2 -pe --grep gps/i DSC_3348.jpg
Exif.Image.GPSTag                            Long        1  15236
Exif.GPSInfo.GPSVersionID                    Byte        4  2 3 0 0
Exif.GPSInfo.GPSLatitudeRef                  Ascii       2  N
Exif.GPSInfo.GPSLatitude                     Rational    3  52/1 378406/10000 0/1
Exif.GPSInfo.GPSLongitudeRef                 Ascii       2  E
Exif.GPSInfo.GPSLongitude                    Rational    3  1/1 180999/10000 0/1
Exif.GPSInfo.GPSAltitudeRef                  Byte        1  0
Exif.GPSInfo.GPSAltitude                     Rational    1  9/1
Exif.GPSInfo.GPSTimeStamp                    Rational    3  10/1 19/1 2135/100
Exif.GPSInfo.GPSSatellites                   Ascii       3  06
Exif.GPSInfo.GPSMapDatum                     Ascii      17  WGS-84          
Exif.GPSInfo.GPSDateStamp                    Ascii      11  2017:03:28
531 rmills@rmillsmbp:~/Pictures/2017/Norwich $ 

You'll need to put the script together from those components. You can use bash, perl, python, cmd.exe or any scripting language from which you can invoke exiv2(.exe). Let me know if you need more assistance.

Here's my image which I took in Norwich, England on Tuesday this week with a Nikon 5300 which has GPS to (optionally) geotag images: http://dev.exiv2.org/attachments/download/1147/DSC_3337.jpg

RE: Gps Tag Latest Image - Remove GPS tag from other jpg - Added by Robin Mills over 4 years ago

Adding a thumbnail version of DSC_3337.jpg

thumb.jpg (56.3 KB) thumb.jpg

RE: Gps Tag Latest Image - Remove GPS tag from other jpg - Added by Robin Mills over 4 years ago

Another observation about this is to only geotag the first image. If all the images arrive in the same directory, you can count the files. If there is ONE Image geotag it, else do nothing.

RE: Gps Tag Latest Image - Remove GPS tag from other jpg - Added by Lee Griffiths over 4 years ago

Great thanks for the advise - will give it a crack

    (1-4/4)