3
$\begingroup$

I need to extract the GPS coordinates from the Exif information of a series of image. This used to work in Mathematica 11.0.0 (on MacOSX):

Import[zf, {"Exif", {"GPSLatitude", "GPSLongitude", "GPSAltitude", "DateTime"}}]

(where zf contains the file path to the photo image).

Unfortunately in Mathematica 11.0.1 this does no longer work. I have seen a previous question/answer using image=Import[zf,"ImageWithExif"] and then digging out the values using complicated manipulations of Options[image,Metainformation]. Is this a bug in 11.0.1? or did my previous variant work by chance but is not syntactically correct?

Should also add that using image=Import[zf,"ImageWithExif"] and then extracting the info with Options[image,Metainformation] is terribly inefficient. The original variant was much faster.

$\endgroup$
2

2 Answers 2

3
$\begingroup$

The solution is much simpler: I get the GPS info directly with:

Import[zf,{{"GeoPosition","DateTime"}}]

This is also very efficient. Still strange why the old syntax does not work anymore.

$\endgroup$
1
  • 1
    $\begingroup$ However, this is does not work for particular locations - see this picture: oc.bgc-jena.mpg.de/index.php/s/ptzW3W9JyOlPVZv Using the Import[zf,{{GeoPosition}}] retrieves a corrupt GPSAltitude, even though it is correctly listed in the EXIF info of the file. This definitely is a bug. $\endgroup$
    – hippo3773
    Dec 20, 2016 at 13:33
0
$\begingroup$

Lets take the following image and save it somewhere (in my case to f:\test.jpg)

enter image description here

Then I execute (MMA 11.0.1):

Import["F:\\test.jpg", {"Exif", {"GPSLatitude", "GPSLongitude", 
   "GPSAltitude", "DateTime"}}]

The output is (contains gps data):

<|"Make" -> "Apple", "Model" -> "iPhone 4", 
 "Orientation" -> <|"CameraTopOrientation" -> Top, 
   "Mirrored" -> False|>, "XResolution" -> 72, "YResolution" -> 72, 
 "ResolutionUnit" -> "inch", "Software" -> "4.3.5", 
 "DateTime" -> 
  DateObject[{2011, 9, 4}, TimeObject[{12, 51, 11.}, TimeZone -> 1.], 
   TimeZone -> 1.], "ExposureTime" -> Quantity[1/3016, "Seconds"], 
 "FNumber" -> "f/2.8", "ExposureProgram" -> "Auto", 
 "ISOSpeedRatings" -> 80, "ExifVersion" -> "2.21", 
 "DateTimeOriginal" -> 
  DateObject[{2011, 9, 4}, TimeObject[{12, 51, 11.}, TimeZone -> 1.], 
   TimeZone -> 1.], 
 "DateTimeDigitized" -> 
  DateObject[{2011, 9, 4}, TimeObject[{12, 51, 11.}, TimeZone -> 1.], 
   TimeZone -> 1.], "ComponentsConfiguration" -> "YCbCr", 
 "ShutterSpeedValue" -> 11.5587, "ApertureValue" -> 2.8, 
 "MeteringMode" -> "Multi-segment", 
 "FlashInfo" -> <|"FlashUsed" -> False, 
   "FlashFiringStatus" -> "No strobe return detection function", 
   "FlashMode" -> Missing["Unknown"], "FlashFunctionPresent" -> True, 
   "RedEyeCorrection" -> False|>, 
 "FocalLength" -> Quantity[3.8, "Millimeters"], 
 "FlashpixVersion" -> "1.00", "ColorSpace" -> "RGBColor", 
 "PixelXDimension" -> 1024, "PixelYDimension" -> 765, 
 "SensingMethod" -> "One-chip color area", 
 "CustomRendered" -> Missing["Disputed"], "ExposureMode" -> "Auto", 
 "WhiteBalance" -> "Auto", "SceneCaptureType" -> "Standard", 
 "GPSLatitudeRef" -> "North", 
 "GPSLatitude" -> Quantity[38.9098, "AngularDegrees"], 
 "GPSLongitudeRef" -> "East", 
 "GPSLongitude" -> Quantity[1.43867, "AngularDegrees"], 
 "GPSAltitudeRef" -> "AboveSeaLevel", 
 "GPSAltitude" -> Quantity[Select[0, NumberQ[#1] &], "Meters"], 
 "GPSTimeStamp" -> TimeObject[{11, 7, 47.}, TimeZone -> 1.], 
 "GPSImgDirectionRef" -> "True direction", 
 "GPSImgDirection" -> Quantity[5338/65, "AngularDegrees"], 
 "GPSDateStamp" -> DateObject[{2011, 9, 4}]|>
$\endgroup$
3
  • 1
    $\begingroup$ Hmm, trying to take the image directly from imgur fails: Import["https://i.stack.imgur.com/qioMG.jpg", {"Exif", {"GPSLatitude", "GPSLongitude", "GPSAltitude", "DateTime"}}]. I wonder why... $\endgroup$ Dec 20, 2016 at 11:32
  • $\begingroup$ Indeed, this syntax is broken under Mathematica 11.0.1 on MacOS. $\endgroup$
    – hippo3773
    Dec 20, 2016 at 12:11
  • $\begingroup$ @J. M. I am also confused that it does not work with image from imgur. From HD it works. $\endgroup$
    – mrz
    Dec 20, 2016 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.