Faster alternatives vs. using exiftool to check lat/lon metadata

Started by TomD, April 14, 2024, 06:50:51 PM

Previous topic - Next topic

TomD

Hi, I'm planning to use exiftool to strip GPS lat/lon from image uploads, based on user preference.  Basically if a user uploads an image with GPS coordinates, it alerts them and gives them the option to strip location before submitting their post.  To speed up the check while processing the upload in php, I'm considering using the inbuilt php functions to check for GPSLatitude or GPSLongitude EXIF tags, as well as the XMP block for <*GPSL*> as that takes ~0.001 seconds in php vs. ~0.2 seconds shelling out to exiftool from php.  Thoughts?  Is what I'm doing in php equivalent to checking for GPSL* with exiftool?  Or should I be checking for more stuff in the XMP?  I'm not that familiar with XMP tags, thanks!

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

TomD

Any image format can be uploaded, but if the mime type is not gif, jpeg or png it gets converted to jpeg.  So pretty much only need to worry about jpeg or png.  For png I would leverage exiftool regardless as php can't read exif for png.

Phil Harvey

OK then.  For JPEG your idea of looking for EXIF GPS tags and doing a brute force search for GPS in the XMP should work for most cases.  In XMP, you might want to qualify it with the namespace prefix and search for "exif:GPSL".

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

TomD

Thanks!  One more question, would the XMP always have the exif: prefix before GPS?  Also, do I need to worry about case or will it always be lowercase exif: followed by uppercase GPSL in the XMP for the Lat/Lon tags?

Phil Harvey

I've never seen anything but a lower-case "exif" for the namespace prefix, but technically anything is possible.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).