Skip to main content
Participant
July 1, 2022
Answered

Using ImageGetEXIFMetaData to try to get gps coordinates of an image

  • July 1, 2022
  • 4 replies
  • 1486 views

I have found 10 year old examples on the net showing the coordinates included in the returned query, but when I try it on my CF 2021 server, those coordinates are not there, not even referenced in the cfdump. Has this function changed over time?

This topic has been closed for replies.
Correct answer Charlie Arehart

Kevin, you say "Since I may receive images without gps data, my solution needs to account for that and I cannot use this approach".

 

Do you mean simply that you can't use this function to detect whether gps data is available? That's not so. You absolutely can.

 

Just test for whether those struct keys exist in the result, using structKeyExists(imgobj. GetExifMetadata(),"GPS Latitude"). If it's true, there's gps data. 

 

Or is there still some reason you feel this won't help? Please help us help you. 

 


Kevin and I spoke offline. He's clarified that what he means is that he now realizes the problem is indeed that his images don't HAVE the GPS data, and when he says "so this solution won't work for me", he means he won't be able to do the sort of processing of images he'd hoped to do. It's clear now that his problem was not the inability of CF or this function to work to GET any GPS data, which is how it originally read (to me, at least).

 

And perhaps someone will get value from all the other info shared in the thread, from all of us. But it seems otherwise we can regard this as case closed.

4 replies

James Moberg
Inspiring
July 6, 2022

Do you have the ability to drop down to the command line using CFExecute?  If so, I recommend using Exiv2.  Here's a UDF that I've been using for 6 years now.  Enjoy!

https://dev.to/gamesover/use-exiv2-to-extract-gps-data-from-images-using-cfml-3maa

NOTE: We used this with a mystery shopping company's agents to ensure that photos contained GPS data and then used the metadata to compare and ensure that single photos weren't being used multiple times.
Please note your mileage may vary as not all images have GPS data.

Charlie Arehart
Community Expert
Community Expert
July 5, 2022

Klemke, how did things go? Especially if you considered what I'd offered.

/Charlie (troubleshooter, carehart. org)
klemkeAuthor
Participant
July 5, 2022
Even the example sent to me on this forum that had data, didn’t have gps data. I am going to have to find a different solution, which is ok.

Kevin Lemke
Virtual Systems
(701)610-6989
www.vir-sys.com
Charlie Arehart
Community Expert
Community Expert
July 6, 2022

Kevin, no. The problem is not that CF fails to show GPS data. It DOES show that GPS data, if the image has it.

 

Let me clarify first that I didn't realize you were asking about GPS data. Yes, I seee it now in the title, but as you could tell from my first reply, my focus was on the Exif data in general, and I thought you were saying you saw NONE at all (others have reported it, and I demonstrated it). That's why my code and example image links demonstrated how that WOULD work if the image DID have exif metadata.

 

So now you have helped me see that it was gps data specifically. But I will ask you: are you saying you have am image that you know DOES have GPS data in its exif metadata? If so, then the code I offered should show it. As important, so would that jimpl.com site.

 

I press these points, because I just spent a couple minutes finding an image that DOES purpose to have GPS data, and the jimpl site DOES show that GPS data, and finally the code I shared above DOES show CF having it in the dump of the getexifmetadata, for that image. Here first is the image URL:

 

https://github.com/ianare/exif-samples/blob/master/jpg/gps/DSCN0042.jpg?raw=true

 

And second, here is the relevant portion of the cfdump of the getexifmetadata function's result showing that gps data:

GPS Altitude Ref Sea level
GPS Date Stamp 2008:10:23
GPS Img Direction Ref Unknown ()
GPS Latitude 43° 27' 52.04"
GPS Latitude Ref N
GPS Longitude 11° 52' 53.32"
GPS Longitude Ref E
GPS Map Datum WGS-84
GPS Satellites 04
GPS Time-Stamp 14:57:41.37 UTC

 

So I'm curious: do you HAVE an image that you feel DOES have exif gps data? Did you try that image in that jimpl.com site and does THAT SITE confirm there's exif gps data. Again, you can see what it would look like on that site with the image link I shared above. And you can then drop it in as the variable value of the code I share above. It should.

 

If it does not, please elaborate. As BKBK said, an image has to HAVE the gps data for it to be shown. More than that, as my first demo's first commented image shows, an image can have  exif data but NOT have GPS info at all.  It sure seems whatever is amiss for you, it's not about CF but about the image. 

/Charlie (troubleshooter, carehart. org)
BKBK
Community Expert
Community Expert
July 2, 2022

@klemke , note that, first and foremost, the image has to have had GPS location metadata added.

Charlie Arehart
Community Expert
Community Expert
July 2, 2022

I'm pretty sure the problem is simply that the image you're trying just has no exifdata. 🙂 You don't offer an example, but I do below. If you try it with the FIRST image which DOES have exif metadata, the first dump will show it; otherwise, the struct will be empty, as you saw. Just swap the comments in front of the imageread to see the difference.

 

<cfscript>
//imgObj = imageRead("https://github.com/ianare/exif-samples/blob/master/jpg/Canon_40D.jpg?raw=true");
// the above image will show exifmetadata
imgObj = imageRead("https://bennadel-cdn.com/images/header/photos/carol_loffelmann_vicky_ryder.jpg");
// the above image will NOT show exifmetadata
writeDump(imgObj.getEXIFMetadata());
writeDump(imgObj.getMetadata());
writedump(imgobj);
//those can also be written as:
//writeDump(imagegetEXIFMetadata(imgObj));
//writeDump(imagegetMetadata(imgObj));
</cfscript>

 

BTW, you may have found somehow that something else you used showed that there WAS metadata, and you can see in my second two dumps above of either getmetadata or the image alone (and done either of the two ways I offer), even the second image has that sort of "metadata", just not EXIF metadata.

 

And if you may want confirm this other than with CF, there are online tools that will show exif (and general) metadata such as https://jimpl.com , just like you can also right-click an image in Windows and choose properties to see image data in details. All those also will also show only metadata and NOT exif metadata is there is none. Indeed, you can use either of those to check any image of your own that you may have been working with.

 

Let us know how it goes.

/Charlie (troubleshooter, carehart. org)