Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to write GPS data using withMetadata #2767

Closed
thiagupct opened this issue Jun 23, 2021 · 3 comments
Closed

How to write GPS data using withMetadata #2767

thiagupct opened this issue Jun 23, 2021 · 3 comments

Comments

@thiagupct
Copy link

What are you trying to achieve?
Am trying to write GPS data to an image but I can't get it work, Any help is highly appreciated

Have you searched for similar questions?
Yes, I have searched but haven't found any examples

Are you able to provide a minimal, standalone code sample that demonstrates this question?

const image = sharp("./logo.jpg");
image
.withMetadata({ 
	exif: {
		IFD3: { 
			GPSLatitudeRef: "N",
			GPSLatitude: "55/1 43/1 5287/100",
			GPSLongitudeRef: "E",
			GPSLongitude: "37/1 35/1 5571/100",
			GPSAltitudeRef: "Sea level",
			GPSAltitude: "90514/693",
			GPSSpeedRef: "K",
			GPSSpeed: "114272/41081",
			GPSImgDirectionRef: "M",
			GPSImgDirection: "192127/921",
			GPSDestBearingRef: "M",
			GPSDestBearing: "192127/921",
			GPSDateStamp: "2020:07:28",
		}
	} 
})
.toFile('output1.jpg')
.then(info => { 
	console.log(info);
})
.catch(err => { 
	console.log(err);
});

Are you able to provide a sample image that helps explain the question?
image

@lovell
Copy link
Owner

lovell commented Jun 26, 2021

Hi, it look like libexif (used by libvips) considers the tags in the GPS "subdirectory" to be EXIF_FORMAT_UNDEFINED. This means libvips does not currently know how to write them, hence the empty Buffer instances you're seeing.

We'll probably need to make libvips aware of all the possible formats (rational, string etc.) of the various GPS tags listed at https://exiftool.org/TagNames/GPS.html

kleisauke added a commit to kleisauke/libvips that referenced this issue Jul 30, 2022
Make `tag_is_ascii` aware of the EXIF GPS* ASCII tags that are
available since libexif 0.6.23.

See: lovell/sharp#2767
@kleisauke
Copy link
Contributor

I just opened PR libvips/libvips#2966 for this. With that, and the above example, I see:

$ vipsheader -a x.jpg | grep exif-ifd3-GPS
exif-ifd3-GPSLatitudeRef: N (N, ASCII, 2 components, 2 bytes)
exif-ifd3-GPSLatitude: 55/1 43/1 5287/100 (55, 43, 52.87, Rational, 3 components, 24 bytes)
exif-ifd3-GPSLongitudeRef: E (E, ASCII, 2 components, 2 bytes)
exif-ifd3-GPSLongitude: 37/1 35/1 5571/100 (37, 35, 55.71, Rational, 3 components, 24 bytes)
exif-ifd3-GPSAltitudeRef: Sea level (Sea level, Byte, 1 components, 1 bytes)
exif-ifd3-GPSAltitude: 90514/693 (130.612, Rational, 1 components, 8 bytes)
exif-ifd3-GPSSpeedRef: K (K, ASCII, 2 components, 2 bytes)
exif-ifd3-GPSSpeed: 114272/41081 (2.78163, Rational, 1 components, 8 bytes)
exif-ifd3-GPSImgDirectionRef: M (M, ASCII, 2 components, 2 bytes)
exif-ifd3-GPSImgDirection: 192127/921 (208.607, Rational, 1 components, 8 bytes)
exif-ifd3-GPSDestBearingRef: M (M, ASCII, 2 components, 2 bytes)
exif-ifd3-GPSDestBearing: 192127/921 (208.607, Rational, 1 components, 8 bytes)
exif-ifd3-GPSDateStamp: 2020:07:28 (2020:07:28, ASCII, 11 components, 11 bytes)

jcupitt pushed a commit to libvips/libvips that referenced this issue Jul 30, 2022
* Allow to modify/create EXIF GPS* tags

Make `tag_is_ascii` aware of the EXIF GPS* ASCII tags that are
available since libexif 0.6.23.

See: lovell/sharp#2767

* Add tests
@lovell lovell added this to the v0.32.0 milestone Dec 27, 2022
@lovell
Copy link
Owner

lovell commented Mar 24, 2023

sharp v0.32.0 is now available with prebuilt binaries that include libvips v8.14.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants