Skip to content

Instantly share code, notes, and snippets.

@mbohun
Last active November 9, 2024 04:44
Show Gist options
  • Save mbohun/32c078775a83685154a777d642a45d1c to your computer and use it in GitHub Desktop.
Save mbohun/32c078775a83685154a777d642a45d1c to your computer and use it in GitHub Desktop.
Xiaomi Redmi Note 13 Pro cam_app GPS TEST

Redmi Note 13 Pro cam_app GPS TEST

  • TODO
for jpg_photo in `ls *.jpg`; do
    raw_lat=$(identify -format '%[exif:GPSLatitude]' ${jpg_photo})
    raw_lon=$(identify -format '%[exif:GPSLongitude]' ${jpg_photo})
    
    lat=$(echo "$raw_lat" | while IFS="," read -r deg min sec; do echo "scale=6;$deg + $min /60 + $sec / 3600"| bc; done)
    lon=$(echo "$raw_lon" | while IFS="," read -r deg min sec; do echo "scale=6;$deg + $min /60 + $sec / 3600"| bc; done)

    #TEST:
    #echo "$jpg_photo,$lat,$lon"
    echo "${jpg_photo}, https://www.openstreetmap.org/?mlat=${lat}&mlon=${lon}&zoom=18"
done
NOTE: Imagemagick identify exif data format example:
mbohun@mamlas:~/pCloudDrive/fungi/Ramaria stricta, Trencianske Teplice, Slovakia > \
    identify -format '%[EXIF:*]' IMG_20240601_152533.jpg | grep GPS

exif:GPSAltitude=36580/100
exif:GPSAltitudeRef=.
exif:GPSDateStamp=2024:06:01
exif:GPSInfo=8532
exif:GPSLatitude=48/1,54/1,21827087/1000000
exif:GPSLatitudeRef=N
exif:GPSLongitude=18/1,11/1,17156066/1000000
exif:GPSLongitudeRef=E
exif:GPSProcessingMethod=GPS
exif:GPSTimeStamp=13/1,25/1,33/1
exif:GPSVersionID=....
#!/bin/bash
FEATURES='[]'
# NOTE: each photo is represented as a geojson Feature in the following format:
#
# {
# "id": 0,
# "type": "Feature",
# "geometry": {
# "coordinates": [
# 18.197613,
# 48.8985345
# ],
# "type": "Point"
# },
# "properties": {
# "photo": "IMG_20241024_173613.jpg",
# "timestamp": 1730048732
# }
# }
#
# NOTE:
counter_id=0
for jpg_photo in `ls *.jpg`; do
echo "processing geojson feature id: ${counter_id}"
raw_lat=$(identify -format '%[exif:GPSLatitude]' ${jpg_photo})
raw_lon=$(identify -format '%[exif:GPSLongitude]' ${jpg_photo})
lat=$(echo "$raw_lat" | while IFS="," read -r deg min sec; do echo "scale=6;$deg + $min /60 + $sec / 3600"| bc; done)
lon=$(echo "$raw_lon" | while IFS="," read -r deg min sec; do echo "scale=6;$deg + $min /60 + $sec / 3600"| bc; done)
FEATURES=$(echo '{ "id": '${counter_id}', "type": "Feature", "geometry": { "coordinates": ['${lon},${lat}'], "type": "Point"}, "properties": { "photo": "\
'${jpg_photo}'" } }' | jq --argjson features "$FEATURES" '$features + [.]')
counter_id=$((counter_id + 1))
done
echo '{ "type": "FeatureCollection" }' \
| jq --argjson features "$FEATURES" '.["features"]=$features' > album.geojson
@mbohun
Copy link
Author

mbohun commented Oct 26, 2024

TODO: photo_album_2_geojson.sh

@mbohun
Copy link
Author

mbohun commented Nov 1, 2024

Megapixels-1.7.0 on Pine64 PinePhone (1.2) does NOT write any exif GPS metadata ?

identify -format '%[exif:*]' IMG20241101005350.stacked.jpg
exif:ColorSpace=1
exif:ComponentsConfiguration=...
exif:DateTime=2024:11:01 00:53:50
exif:DateTimeDigitized=2024:11:01 00:53:50
exif:DateTimeOriginal=2024:11:01 00:53:50
exif:ExifOffset=90
exif:ExifVersion=0210
exif:ExposureProgram=2
exif:ExposureTime=2304/100000
exif:Flash=0
exif:FlashPixVersion=0100
exif:FNumber=300000/100000
exif:FocalLength=332999/100000
exif:FocalLengthIn35mmFilm=35
exif:Make=PINE64
exif:Model=PinePhone
exif:PhotographicSensitivity=15528
exif:PixelXDimension=2592
exif:PixelYDimension=1944
exif:ResolutionUnit=2
exif:Software=Megapixels
exif:XResolution=72/1
exif:YCbCrPositioning=1
exif:YResolution=72/1

@mbohun
Copy link
Author

mbohun commented Nov 1, 2024

FIXING / adjusting GPS manually:

exiftool -GPSLatitude=48.9023 -GPSLongitude=18.1875 input.jpg -o output.jpg

@mbohun
Copy link
Author

mbohun commented Nov 1, 2024

ADDING missing GPS manually:

lat=-35.403489&lon=149.062468

@mbohun
Copy link
Author

mbohun commented Nov 9, 2024

GEOJSON Polygon test

{
      "type": "Feature",
      "properties": {},
      "geometry": {
        "coordinates": [
          [
            [
              18.18652154778826,
              48.90401309469868
            ],
            [
              18.18669787196461,
              48.90384400281701
            ],
            [
              18.18672594648669,
              48.9034477954784
            ],
            [
              18.186786312180686,
              48.90342456377698
            ],
            [
              18.186838208449956,
              48.903576868936256
            ],
            [
              18.187140059981374,
              48.903850544716335
            ],
            [
              18.187094765148856,
              48.90410152529216
            ],
            [
              18.186927512776492,
              48.90420496405508
            ],
            [
              18.186629983202153,
              48.90415607154813
            ],
            [
              18.18652154778826,
              48.90401309469868
            ]
          ]
        ],
        "type": "Polygon"
      }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment