z_media_preview (zotonic_core v1.0.0-rc.17)
Make still previews of media, using image manipulation functions. Resize, crop, grey, etc. This uses the command line imagemagick tools for all image manipulation.
Summary
Functions
Check if we can generate a preview image of the given mime type
Map filters to commandline options
Convert the Infile to an outfile with a still image using the filters.
Detect the ImageMagick executable using the supplied finder function. The finder has the same signature as os:find_executable/1 and returns either a path string or false. Separating this logic from the caching wrapper makes the v6/v7 detection deterministically testable.
Return the preferred mime type of the image generated by resizing an image of a certain type and size.
Determine the output mime type, after expanding optional mediaclass arguments.
Calculate the size of the resulting image.
Map the list of known filters and known args to atoms. Used when mapping preview urls back to filter args.
Functions
Check if we can generate a preview image of the given mime type
Map filters to commandline options
-spec convert(InFile, OutFile, Filters, Context) -> ok | {error, Reason} when InFile :: file:filename_all(), OutFile :: file:filename_all(), Filters :: list(), Context :: z:context(), Reason :: will_overwrite_infile | term().
Convert the Infile to an outfile with a still image using the filters.
-spec imagemagick_detect(FindExe) -> #{cmd := string() | false, legacy := boolean()} when FindExe :: fun((string()) -> string() | false).
Detect the ImageMagick executable using the supplied finder function. The finder has the same signature as os:find_executable/1 and returns either a path string or false. Separating this logic from the caching wrapper makes the v6/v7 detection deterministically testable.
-spec is_legacy_imagemagick() -> boolean().
Return the preferred mime type of the image generated by resizing an image of a certain type and size.
Determine the output mime type, after expanding optional mediaclass arguments.
Calculate the size of the resulting image.
Map the list of known filters and known args to atoms. Used when mapping preview urls back to filter args.