-
Notifications
You must be signed in to change notification settings - Fork 21
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
Convert reference to binary data (header_value) #16
Comments
Hi @kipcole9, thanks for the complements :) Agree with you. I think just returning the binary blob for Just curious, you want to just fetch the exif-data blob and parse it outside? I'm asking because you can get parsed exif data fields as strings directly (it uses libexif). {:ok, field_names} = Vix.Vips.Image.header_field_names(img)
field_names
|> Enum.filter(&String.starts_with?(&1, "exif-if"))
|> Enum.map(fn field_name ->
{:ok, value} = Vix.Vips.Image.header_value(img, field_name)
IO.puts(field_name <> " = " <> value)
end)
No need, I'm beginner to libvips too :) |
Oh, now I feel a little silly - thanks for the pointer. Yes, I have been doing my own exif decoding (leaning on prior work). Your example code is very helpful however the return from iex> {:ok, value} = Vix.Vips.Image.header_value(img, "exif-ifd2-ShutterSpeedValue")
{:ok, "exif-ifd2-ShutterSpeedValue = 8321928/1000000 (8.32 EV (1/320 sec.), SRational, 1 components, 8 bytes)"} Which seems to be the inherent noisiness of Anyway, thanks for the engagement and feel free to close the issue! (look forward to a raw binary return from |
I see. Agree that current output is noisy. Probably this is relevant: kleisauke/net-vips#74 (comment) If possible, can you try https://github.com/akash-akya/vix/tree/vips-blob branch for the getting the blob as binary? Tried this Mix.install([
{:vix, git: "[email protected]:akash-akya/vix.git", branch: "vips-blob" }
])
{:ok, img} = Vix.Vips.Image.new_from_file("~/Downloads/Canon_DIGITAL_IXUS_400.jpg")
{:ok, exif_data} = Vix.Vips.Image.header_value(img, "exif-data")
File.write!("exif.dat", exif_data) |
Thats great news, thank you. Will try that out in a few hours. I'll stick with doing my own Exif decoding for now since I also need to decode XMP data (and maybe later IPTC data). And it may actually be more efficient since its only one NIF call. Are you open to PRs to add some additional functions like |
Have implemented the |
Nice! I'll close the issue once the change is merged.
That's great. Yes, all kinds of contributions are welcome. Thank you for taking time to raise the issue and testing it. |
Thanks for building this library, amazing work! I'm not an experienced libvips user so apologies if this is a very naive question. I'm aiming to decode the "exif-data" chunk of an image.
If there a way to convert the reference to the underlying binary data? I know I can:
I assume I can then
decode_base64
back to the binary blob but that seems more conversion work than necessary.Is there any way to return the underlying binary blob for a header field?
The text was updated successfully, but these errors were encountered: