z_media_identify (zotonic_core v1.0.0-rc.17)
Identify files, fetch metadata about an image
Summary
Functions
Return the extension for a known mime type (eg. ".mov").
Return the extension for a known mime type (eg. ".mov"). When multiple extensions are found for the given mime type, returns the one that is given as the preferred extension. Otherwise, it returns the first extension.
Guess the mime type of a file by the extension of its filename.
Caching version of identify/3. Fetches information about an image, returns width, height, type, etc.
Fetch information about a file, returns mime, width, height, type, etc. First checks if a module has a specific identification methods.
Fetch information about a file, returns mime, width, height, type, etc.
Given a mime type, return whether its file contents is already compressed or not.
Types
-type filename_extension() :: binary().
-type media_info() :: map().
-type mime_type() :: binary().
-type optional_filename() :: undefined | file:filename_all().
-type os_family() :: win32 | unix.
Functions
-spec extension(Mime) -> filename_extension() when Mime :: string() | binary() | cow_http_hd:media_type().
Return the extension for a known mime type (eg. ".mov").
-spec extension(Mime, PreferExtension) -> filename_extension() when Mime :: string() | binary() | cow_http_hd:media_type(), PreferExtension :: string() | binary() | undefined.
-spec extension(Mime, PreferExtension, z:context()) -> filename_extension() when Mime :: string() | binary() | cow_http_hd:media_type(), PreferExtension :: string() | binary() | undefined.
Return the extension for a known mime type (eg. ".mov"). When multiple extensions are found for the given mime type, returns the one that is given as the preferred extension. Otherwise, it returns the first extension.
-spec guess_mime(file:filename_all()) -> mime_type().
Guess the mime type of a file by the extension of its filename.
-spec identify(#upload{filename :: binary() | undefined, tmpfile :: file:filename_all() | undefined, tmpmonitor :: undefined | pid(), data :: binary() | undefined, mime :: binary() | undefined} | file:filename_all(), z:context()) -> {ok, media_info()} | {error, term()}.
Caching version of identify/3. Fetches information about an image, returns width, height, type, etc.
-spec identify(#upload{filename :: binary() | undefined, tmpfile :: file:filename_all() | undefined, tmpmonitor :: undefined | pid(), data :: binary() | undefined, mime :: binary() | undefined} | file:filename_all(), optional_filename(), z:context()) -> {ok, media_info()} | {error, term()}.
-spec identify_file(file:filename_all(), z:context()) -> {ok, media_info()} | {error, term()}.
Fetch information about a file, returns mime, width, height, type, etc. First checks if a module has a specific identification methods.
-spec identify_file(file:filename_all(), optional_filename(), z:context()) -> {ok, media_info()} | {error, term()}.
-spec identify_file_direct(file:filename_all(), optional_filename()) -> {ok, media_info()} | {error, term()}.
Fetch information about a file, returns mime, width, height, type, etc.
Given a mime type, return whether its file contents is already compressed or not.