question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Writing EXIF

See original GitHub issue

Hello there,

Hoping this is a quick one. How to insert IFD2/Lens tags into an image? I was able to set many other tags without any issues, anything related to Lens info (exif-ifd2-LensModel, exif-ifd2-LensSpecification, exif-ifd2-LensSerialNumber, exif-ifd2-LensMake) does not seem to work.

            using var image = NetVips.Image.NewFromFile(Path.Join(_path, "img_no_exif.jpg"));
            image.Mutate(m => m.Set(GValue.GStrType, "exif-ifd2-LensMake", "Canon"));
            image.WriteToFile(Path.Combine(_path, "img_with_lens_info.jpg"));

            using var exifed = NetVips.Image.NewFromFile(Path.Join(_path, "img_with_lens_info.jpg"));
            bool hasLensMake = exifed.Contains("exif-ifd2-LensMake");

Side note: I tried both GValue.GStrType and GValue.RefStrType with no luck. For other tags, I figured out how to successfully set certain values through trial and error - for example, while working with other numeric fields (say exif-ifd2-FNumber), instead of directly using GValue.GDoubleType I had to convert it to a rational string and then use the type GValue.RefStrType to successfully set. But this simple string field, I just can’t get to the bottom of it.

Thank you in advance!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kleisaukecommented, May 10, 2022

We aim for a release in late May, see: https://github.com/libvips/libvips/issues/2790. Setting exif-ifd2-LensSpecification should be possible after PR https://github.com/libexif/libexif/pull/85, e.g.:

using var image = Image.Black(100, 100);
using var mutated = image.Mutate(m => m.Set(GValue.GStrType, "exif-ifd2-LensSpecification", "5/1 10/1 100/1 200/1"));
mutated.WriteToFile("x2.jpg");

using var image2 = Image.NewFromFile("x2.jpg");
Debug.Assert(image2.Contains("exif-ifd2-LensSpecification"));
0reactions
jeromenelsoncommented, Jul 31, 2022

Thank you, super excited about the other new features as well!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does writing EXIF tags influence jpeg quality?
There are tags that affect how the image can be interpreted by software (think about orientation), but no, the image bits should not...
Read more >
Writing EXIF data into Photos - Questions & Suggestions
I found this great article about READING EXIF data from photos: ... Writing EXIF data into Photos · Questions & Suggestions · photos....
Read more >
Writing EXIF coordinates to images based on common field?
Now I need to write the new coordinates into the images EXIF data (re-geocode images), using the image name as the matching field....
Read more >
How to write or modify EXIF data for an existing image on ...
You can use libexif - I've had success with compiling it for iOS before. With libexif, you can modify any image's EXIF metadata....
Read more >
Proper formatting for writing EXIF gps data to jpg
Hello,. I'm attempting to geotag photos with FME Desktop by writing coordinates to the jpgs with an AttributeCreator.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found