- Erlang/OTP R16 or higher (17 or higher for EXIF in maps)
- rebar 2.x
To build the application and run the test suite, use rebar like so:
$ rebar compile
$ rebar ct
To add erlang-exif as a dependency to your rebar-based project, simply add the following to your rebar.config file, then run the rebar get-deps command to retrieve it.
{deps, [
{exif, ".*", {git, "https://github.com/nlfiedler/erlang-exif", {tag, "2.0.3"}}}
]}.
The exif:read(Path) function actually calls exif:read(Path, dict) (for backward compatibility).
The 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.
If no such values are present, the structure will be empty.
However, if there was an error, an {error, Reason} tuple will be returned, where Reason is nearly always invalid_exif.
case exif:read(Path, dict) of
{error, Reason} ->
error_logger:error_msg("Unable to read EXIF data from ~s, ~p~n", [Path, Reason]);
{ok, ExifData} ->
case dict:find(date_time_original, ExifData) of
{ok, Original} ->
% do something with the date...
ok;
error ->
error_logger:info_msg("No original date available")
end
end.
Two more functions are present: exif:read_binary/1 and exif:read_binary/2 which are equivalents of exif:read/1,2.
They accept actual file in binary format as a first argument, instead of a path.