Skip to content

Commit 64f8c16

Browse files
committed
add partial clap atom parsing to HEIF
1 parent 22bf034 commit 64f8c16

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/ex_image_info/types/heif.ex

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,21 @@ defmodule ExImageInfo.Types.HEIF do
4646
if length(ispe_boxes) > 0 do
4747
{width, height} =
4848
ispe_boxes
49-
|> Enum.map(fn <<_::size(32), width::size(32), height::size(32), _rest::binary>> ->
50-
{width, height}
49+
|> Enum.map(fn <<_::size(32), width::size(32), height::size(32), rest::binary>> ->
50+
[_ispe | clap] = String.split(rest, "clap")
51+
52+
if length(clap) > 0 do
53+
<<clap_width_n::size(32), clap_width_d::size(32), clap_height_n::size(32),
54+
clap_height_d::size(32), _horizontal_offset_n::size(32),
55+
_horizontal_offset_d::size(32), _vertical_offset_n::size(32),
56+
_vertical_offset_d::size(32), _rest::binary>> = List.first(clap)
57+
58+
clap_width = round(clap_width_n / clap_width_d)
59+
clap_height = round(clap_height_n / clap_height_d)
60+
{clap_width, clap_height}
61+
else
62+
{width, height}
63+
end
5164
end)
5265
|> Enum.max_by(&elem(&1, 0))
5366

0 commit comments

Comments
 (0)