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.

Write string EXIF-tags with libvips

See original GitHub issue

Hi,

I’ve got a problem with writing meta data to a JPEG file. I suppose this must be because of a datatype mismatch.

Here’s a little example program, where I experience this error:

var vipsImage = NetVips.Image.NewFromFile("test.jpg"); // Load iamge

System.Console.WriteLine("Old orientation: " + vipsImage.Get("orientation"));
vipsImage.Set("orientation", 2); // Change orientation
System.Console.WriteLine("New orientation: " + vipsImage.Get("orientation"));

System.Console.WriteLine("Old key words: " + vipsImage.Get("exif-ifd0-XPKeywords"));
vipsImage.Set("exif-ifd0-XPKeywords", "test keyword"); // Change key words
System.Console.WriteLine("New key words: " + vipsImage.Get("exif-ifd0-XPKeywords"));

vipsImage.Jpegsave("result.jpg"); // Write to file

var reloadedImage = NetVips.Image.NewFromFile("result.jpg"); // Reload file

System.Console.WriteLine("Orientation after reload: " + reloadedImage.Get("orientation"));
System.Console.WriteLine("Key words after reload: " + vipsImage.Get("exif-ifd0-XPKeywords"));

(Note: For the above code snippet to work, the Tags field in Properties => Details of the loaded JPEG file must at least have one tag set. Otherwise, of course, vipsImage.Get(“exif-ifd0-XPKeywords”) will fail)

and the corresponding output:

Old orientation: 1
New orientation: 2
Old key words: Test-Tag (Test-Tag, Byte, 18 components, 18 bytes)
New key words: test keyword
Orientation after reload: 2
Key words after reload: Test-Tag (Test-Tag, Byte, 18 components, 18 bytes)

As you can see, I’m able to set a new orientation in meta data and after saving the file to disk (doesn’t matter if I use Jpegsave or WriteToFile) and reloading the saved file again, the orientation still has my changed value but the exif-ifd0-XPKeywords field doesn’t. Now my guess is, this behavior is caused by a type mismatch of the exif-ifd0-XPKeywords field and the string i try to save into it. But the only hint I have is the different output of “Old keywords” and “New key words”. Looking at the byte information in the “Old key words”-output i suppose i have to save the “test keyword”-string in a different way. But I don’t know how. And also i don’t know why, because before saving the image to disc, the changes seem to have an effect.

By debugging I saw that the type of this field is GValue.RefStrType and the part of the method GValue.Set() for GValue.RefStrType equals the part for GValue.GStrType while the GValue.Get() method differs at this point.

Now my question: Is this an error in NetVips or is the error in front of my keyboard? 😃

I hope my problem is understandable and I’m thankful for any hint on how to properly save key words in the exif data. If you need any further information, don’t hesitate to ask.

Thank You

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
jcupittcommented, Jul 4, 2018

OK, I think I’ve fixed ImageDescription.

libexif has three different types of string write 😦 yuk!

0reactions
kleisaukecommented, Sep 25, 2018

I’ve just released NetVips 1.0.5 which bundle and depend upon libvips 8.7.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VIPS: libvips/foreign/exif.c
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code...
Read more >
A fast image processing library with low memory needs.
Normally any orientation tags on the input image (such as EXIF tags) are interpreted to rotate the image upright. If you set no_rotate...
Read more >
Ruby-vips getting EXIF orientation
How to update EXIF tags of a picture file in Ruby? 1 · Can't set image orientation with ImageMagick · 1 · Editing...
Read more >
Image — pyvips 2.2.1 documentation
Ignored for list inputs The libvips interpretation of the array. If None, the interpretation defaults to the pyvips one for Image.new_from_memory . If...
Read more >
ExifTags Module - Pillow (PIL Fork) 10.0.0 documentation
The ExifTags module exposes several enum.IntEnum classes which provide constants and clear-text names for various well-known EXIF tags. PIL.ExifTags.
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