@@ -125,9 +125,10 @@ defmodule ExImageInfo do
125125 :pnm
126126 ]
127127
128- @ typedoc "The supported image formats ."
128+ @ typedoc "Supported image format types ."
129129 @ type image_format ::
130130 :jpeg
131+ | :jpg
131132 | :png
132133 | :webp
133134 | :avif
@@ -141,8 +142,6 @@ defmodule ExImageInfo do
141142 | :jp2
142143 | :pnm
143144
144- ## Public API
145-
146145 @ doc """
147146 Detects if the given binary seems to be in the given image format.
148147
@@ -171,7 +170,7 @@ defmodule ExImageInfo do
171170 maybe_png_binary |> ExImageInfo.seems? :png
172171 # false
173172 """
174- @ spec seems? ( binary , format :: atom ) :: boolean | nil
173+ @ spec seems? ( binary , format :: image_format ( ) ) :: boolean
175174 def seems? ( binary , format )
176175 def seems? ( binary , :png ) , do: PNG . seems? ( binary )
177176 def seems? ( binary , :gif ) , do: GIF . seems? ( binary )
@@ -187,7 +186,6 @@ defmodule ExImageInfo do
187186 def seems? ( binary , :avif ) , do: AVIF . seems? ( binary )
188187 def seems? ( binary , :heic ) , do: HEIC . seems? ( binary )
189188 def seems? ( binary , :heif ) , do: HEIF . seems? ( binary )
190- def seems? ( _ , _ ) , do: nil
191189
192190 @ doc """
193191 Detects the image format that seems to be the given binary (*guessed* version of `ExImageInfo.seems?/2`).
@@ -245,7 +243,7 @@ defmodule ExImageInfo do
245243 maybe_png_binary |> ExImageInfo.type :png
246244 # nil
247245 """
248- @ spec type ( binary , format :: atom ) ::
246+ @ spec type ( binary , format :: image_format ( ) ) ::
249247 { mimetype :: String . t ( ) , variant :: String . t ( ) } | nil
250248 def type ( binary , format )
251249 def type ( binary , :png ) , do: PNG . type ( binary )
@@ -262,7 +260,6 @@ defmodule ExImageInfo do
262260 def type ( binary , :avif ) , do: AVIF . type ( binary )
263261 def type ( binary , :heic ) , do: HEIC . type ( binary )
264262 def type ( binary , :heif ) , do: HEIF . type ( binary )
265- def type ( _ , _ ) , do: nil
266263
267264 @ doc """
268265 Gets the mime-type and variant type for the given image binary (*guessed* version of `ExImageInfo.type/2`).
@@ -322,7 +319,7 @@ defmodule ExImageInfo do
322319 {ExImageInfo.type(malformed_heif_binary, :heif), ExImageInfo.info(malformed_heif_binary, :heif)}
323320 # {{"image/heif", "HEIF"}, nil}
324321 """
325- @ spec info ( binary , format :: atom ) ::
322+ @ spec info ( binary , format :: image_format ( ) ) ::
326323 { mimetype :: String . t ( ) , width :: integer ( ) , height :: integer ( ) ,
327324 variant :: String . t ( ) }
328325 | nil
@@ -341,7 +338,6 @@ defmodule ExImageInfo do
341338 def info ( binary , :avif ) , do: AVIF . info ( binary )
342339 def info ( binary , :heic ) , do: HEIC . info ( binary )
343340 def info ( binary , :heif ) , do: HEIF . info ( binary )
344- def info ( _ , _ ) , do: nil
345341
346342 @ doc """
347343 Gets the mime-type, variant-type and dimensions (width, height) for the given image binary
@@ -372,16 +368,12 @@ defmodule ExImageInfo do
372368 | nil
373369 def info ( binary ) , do: try_info ( binary , @ types )
374370
375- ## Private
376-
377- @ doc false
378371 defp try_seems? ( _binary , [ ] ) , do: nil
379372
380373 defp try_seems? ( binary , [ type | types ] ) do
381374 if seems? ( binary , type ) , do: type , else: try_seems? ( binary , types )
382375 end
383376
384- @ doc false
385377 defp try_type ( _binary , [ ] ) , do: nil
386378
387379 defp try_type ( binary , [ type | types ] ) do
@@ -391,7 +383,6 @@ defmodule ExImageInfo do
391383 end
392384 end
393385
394- @ doc false
395386 defp try_info ( _binary , [ ] ) , do: nil
396387
397388 defp try_info ( binary , [ type | types ] ) do
0 commit comments