Module z_media_preview

Make still previews of media, using image manipulation functions.

Copyright © 2009-2021 Marc Worrell

Authors: Marc Worrell (marc@worrell.nl).

Description

Make still previews of media, using image manipulation functions. Resize, crop, grey, etc. This uses the command line imagemagick tools for all image manipulation. This code is adapted from PHP GD2 code, so the resize/crop could've been done more efficiently, but it works :-)

Function Index

calc_size/1
can_generate_preview/1Check if we can generate a preview image of the given mime type.
cmd_args/3Map filters to commandline options.
convert/4Convert the Infile to an outfile with a still image using the filters.
convert/5
out_mime/2Return the preferred mime type of the image generated by resizing an image of a certain type and size.
out_mime/3Determine the output mime type, after expanding optional mediaclass arguments.
size/3Calculate the size of the resulting image.
string2filter/2Map the list of known filters and known args to atoms.

Function Details

calc_size/1

calc_size(S) -> any()

can_generate_preview/1

can_generate_preview(B::binary() | string()) -> boolean()

Check if we can generate a preview image of the given mime type

cmd_args/3

cmd_args(FileProps, Filters, OutMime) -> any()

Map filters to commandline options

convert/4

convert(InFile::file:filename_all(), OutFile::file:filename_all(), Filters::list(), Context::#context{}) -> ok | {error, term()}

Convert the Infile to an outfile with a still image using the filters.

convert/5

convert(InFile, MediumFilename, OutFile, Filters, Context) -> any()

out_mime/2

out_mime(InMime::binary(), Options::list()) -> {OutMime::binary(), Extension::string()}

Return the preferred mime type of the image generated by resizing an image of a certain type and size.

out_mime/3

out_mime(Mime, Options, Context) -> any()

Determine the output mime type, after expanding optional mediaclass arguments.

size/3

size(Props::MediaRef, Filters, Context) -> {size, Width, Height, ResizedMime} | {error, Reason}

Calculate the size of the resulting image.

string2filter/2

string2filter(Filter::string(), Where::string()) -> {ok, tuple() | atom()} | {error, term()}

Map the list of known filters and known args to atoms. Used when mapping preview urls back to filter args.


Generated by EDoc