• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using ImageGetEXIFMetaData to try to get gps coordinates of an image

Community Beginner ,
Jul 01, 2022 Jul 01, 2022

Copy link to clipboard

Copied

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?

TOPICS
Advanced techniques

Views

796

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 08, 2022 Jul 08, 2022

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 i

...

Votes

Translate

Translate
Community Expert ,
Jul 01, 2022 Jul 01, 2022

Copy link to clipboard

Copied

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2022 Jul 02, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2022 Jul 05, 2022

Copy link to clipboard

Copied

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


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 05, 2022 Jul 05, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2022 Jul 05, 2022

Copy link to clipboard

Copied

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 06, 2022 Jul 06, 2022

Copy link to clipboard

Copied

Thanks for the help. My problem is that I have no control over the images that I want to check for gps data. Since I may receive images without gps data, my solution needs to account for that and I cannot use this approach as I had hoped. No big deal, just need to do things differently. Thanks again for the help.

Kevin Lemke
Virtual Systems
(701)610-6989
www.vir-sys.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 06, 2022 Jul 06, 2022

Copy link to clipboard

Copied

This may already have been covered in the thread. If so, I apologize.

 

If an image has GPS coordinates, they'll be in the EXIF metadata just like anything else that isn't required to display the image. In my personal experience, most images from modern DSLR and mirrorless cameras don't have GPS data because those cameras don't have embedded GPS hardware. You have to add extra hardware for GPS support. Phones do automatically add GPS coordinates to image metadata, because they do have that hardware built in. So, use something like CFTRY/CFCATCH to test for it before you try to use it.

 

Dave Watts, Eidolon LLC 

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 06, 2022 Jul 06, 2022

Copy link to clipboard

Copied

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. 

 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2022 Jul 08, 2022

Copy link to clipboard

Copied

LATEST

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.


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 06, 2022 Jul 06, 2022

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation