Skip to content

Commit

Permalink
Set default return type to maps.
Browse files Browse the repository at this point in the history
  • Loading branch information
mworrell committed Aug 27, 2021
1 parent c9b80eb commit 6251c51
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To add `erlang_exif` as a dependency to your rebar-based project, simply add the

## Example

The `erlang_exif:read(Path)` function actually calls `erlang_exif:read(Path, dict)` (for backward compatibility).
The `erlang_exif:read(Path)` function actually calls `erlang_exif:read(Path, map)`.

The `erlang_exif:read(Path, ReturnType)` function returns `{ok, Exif}` where `Exif` is a `dict:dict()` or a map
of the values read from the JPEG image. `ReturnType` has two valid values: `dict` and `maps`.
Expand Down
17 changes: 10 additions & 7 deletions src/erlang_exif.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
-define(DEBUG(_Fmt, _Args), ok).
-endif.

-type exif() :: dict:dict() | map().
-type exif() :: exif_map() | exif_dict().
-type exif_dict() :: dict:dict().
-type exif_map() :: #{ atom() => term() }.

-type data_module() :: erlang_exif_dict | erlang_exif_maps.
-type return_type() :: dict | maps.
Expand Down Expand Up @@ -80,14 +82,15 @@ read_binary(Data, ReturnType) when is_binary(Data) ->
find_and_parse_exif(ImageData, data_mod(ReturnType)).

%%
%% @doc Read the Exif data from a named file (or binary data).
%% @doc Read the Exif data from a named file (or binary data) and return a
%% a map with the read data.
%%
-spec read(File) -> {ok, Exif} | {error, Reason}
when File :: file:filename_all(),
Exif :: exif(),
Reason :: term().
-spec read(File) -> {ok, ExifMap} | {error, Reason}
when File :: file:filename_all(),
ExifMap :: exif_map(),
Reason :: term().
read(File) when is_list(File); is_binary(File) ->
read(File, dict).
read(File, maps).

%%
%% @doc Read the Exif data from a named file (or binary data)
Expand Down

0 comments on commit 6251c51

Please sign in to comment.