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

Small improvements to exif data decoding #169

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/image/exif/decode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ defmodule Image.Exif.Decode do
def tag(_, 0x9000, value), do: {:exif_version, version(value)}
def tag(_, 0x9003, value), do: {:datetime_original, date_time(value)}
def tag(_, 0x9004, value), do: {:datetime_digitized, date_time(value)}
def tag(_, 0x9011, value), do: {:datetime_original_offset, value}
def tag(_, 0x9012, value), do: {:datetime_digitized_offset, value}
def tag(_, 0x9101, value), do: {:component_configuration, component_configuration(value)}
def tag(_, 0x9102, value), do: {:compressed_bits_per_pixel, value}
def tag(_, 0x9201, value), do: {:shutter_speed_value, value}
Expand Down Expand Up @@ -333,12 +335,20 @@ defmodule Image.Exif.Decode do
defp ycbcr_positioning(2), do: "Co-sited"
defp ycbcr_positioning(other), do: "Unknown (#{other})"

@spec version(charlist()) :: binary()
@spec version(charlist() | binary()) :: binary()
defp version([?0, major, minor1, minor2]) do
<<major, ?., minor1, minor2>>
end

defp version([major1, major2, minor1, minor2]) do
<<major1, major2, ?., minor1, minor2>>
end

defp version(<<?0, major, minor1, minor2>>) do
<<major, ?., minor1, minor2>>
end

defp version(<<major1, major2, minor1, minor2>>) do
<<major1, major2, ?., minor1, minor2>>
end
end