Skip to content

nlfiedler/erlang-exif

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Erlang EXIF Library

Building and Testing

Prerequisites

To build the application and run the test suite, use rebar like so:

$ rebar compile
$ rebar ct

Usage

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"}}}
]}.

Example

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.

About

EXIF reader for Erlang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Erlang 100.0%