blueimp / JavaScript-Load-Image

Load images provided as File or Blob objects or via URL. Retrieve an optionally scaled, cropped or rotated HTML img or canvas element. Use methods to parse image metadata to extract IPTC and Exif tags as well as embedded thumbnail images, to overwrite the Exif Orientation value and to restore the complete image header after resizing.
https://blueimp.github.io/JavaScript-Load-Image/
MIT License
4.45k stars 922 forks source link

How to get exif data of canvas element to fetch geo location in typescript. #128

Closed ashutosh925 closed 3 years ago

ashutosh925 commented 4 years ago

As given here to define typescript variables and signatures, It's expected to get gps coordinates and exif data. but it only returns ImageHead, OriginalHeight, OriginalWidth.

loadImage( fileOrBlobOrUrl, function (img, data) { var gpsInfo = data.exif && data.exif.get('GPSInfo') if (gpsInfo) { // Map of all GPSInfo tags with their mapped names/text as keys/values: console.log(gpsInfo.getAll()) // A specific GPSInfo tag value: console.log(gpsInfo.get('GPSLatitude')) } }, { meta: true } )

since data.exif is undefined I'm not able to get geoLocations, how can i can i get this.

blueimp commented 3 years ago

Hi @ashutosh925,

I don't manage the TypeScript definitions so cannot provide any info on their correctness.

However the data.exif property is only set if the image does have EXIF data available.

Do you have a link to a sample image and have you confirmed that it actually does have EXIF data?

ashutosh925 commented 3 years ago

@blueimp ..thanks@ for responding..! , Actually i was trying to get exif data while capturing image from camera, A canvas element is created when image is captured, since i haven't got exif data for that element, i assumed we don't get exif data when any image is captured or canvas is created, rather we only get exif data of those if we have some canvas/image that's already having exif data. "I'm trying to implement something similar to iphone gallery feature where we can see where the image was captured"

blueimp commented 3 years ago

Closing as solved.