elxvips v0.0.8 Elxvips

Documentation for Elxvips.

Link to this section Summary

Functions

Will create an %ImageByte{} struct from bitstring or byte list. This struct will be used for further processing.

Will create an %ImageFile{} struct from path. This struct will be used for further processing.

Returns format of the specified image, works with a image path or bytes.

Returns dimensions of the specified image, works with a image path or bytes.

Will save the ImageFile in jpeg format to a specified path. Accepts quality and strip options. By default quality is set to 90 and strip to true.

Will save the ImageFile in png format to a specified path. Accepts quality, compression(0-9) and strip options. By default quality is set to 100, compression to 6, strip to true. Decreasing compression will speed up image saving.

Applies resize options to an %ImageFile{} or %ImageBytes{}, accepts :width, :height and :type (not implemented yet). If no width or height is specified dimensions are calculated from the input image. Empty resize( no :width and no :height) will produce an image with the dimensions as the original one.

Will create a new %ImageBytes{} struct containing all the changes.

Will save the image to a path on disk and return a new %ImageFile{} from the new path.

Will save the ImageFile in webp format to a specified path. Accepts quality and strip options. By default quality is set to 100, and strip to true.

Link to this section Functions

Link to this function

from_bytes(bytes)

Will create an %ImageByte{} struct from bitstring or byte list. This struct will be used for further processing.

Examples

iex> import Elxvips
iex>
iex> file = File.open!( "/path/input.png" )
iex> bytes = IO.binread( file, :all )
iex> from_bytes( bytes )
%ImageBytes{}
Link to this function

from_file(path)

Will create an %ImageFile{} struct from path. This struct will be used for further processing.

Examples

iex> import Elxvips
iex>
iex> from_file( "/path/input.png" )
%ImageFile{}
Link to this function

get_image_format(path)

Returns format of the specified image, works with a image path or bytes.

Examples

iex> import Elxvips
iex>
iex> from_file( "test/input.png" )
iex> |> get_image_format()
{:ok, :png}
Link to this function

get_image_sizes(path)

Returns dimensions of the specified image, works with a image path or bytes.

Examples

iex> import Elxvips
iex>
iex> from_file( "test/input.png" )
iex> |> get_image_sizes()
{:ok, [640, 486]}
Link to this function

jpg(image, opts \\ [])

Will save the ImageFile in jpeg format to a specified path. Accepts quality and strip options. By default quality is set to 90 and strip to true.

Examples

iex> import Elxvips
iex>
iex> from_file( "/path/input.png" )
iex> |> jpg( strip: true, quality: 72 )
iex  |> to_file( "/path/output.jpg" )
{ :ok, %ImageFile{} }
Link to this function

png(image, opts \\ [])

Will save the ImageFile in png format to a specified path. Accepts quality, compression(0-9) and strip options. By default quality is set to 100, compression to 6, strip to true. Decreasing compression will speed up image saving.

Examples

iex> import Elxvips
iex>
iex> from_file( "/path/input.jpg" )
iex> |> png( strip: true, quality: 72 )
iex  |> to_file( "/path/output.png" )
{ :ok, %ImageFile{} }
Link to this function

resize(image_file, opts \\ [])

Applies resize options to an %ImageFile{} or %ImageBytes{}, accepts :width, :height and :type (not implemented yet). If no width or height is specified dimensions are calculated from the input image. Empty resize( no :width and no :height) will produce an image with the dimensions as the original one.

Examples

iex> import Elxvips
iex>
iex> from_file( "test/input.png" )
iex> |> resize( width: 300 )
iex  |> to_bytes()
{:ok, %ImageBytes{}}
Link to this function

set_concurrency(concurrency)

Link to this function

to_bytes(image)

Will create a new %ImageBytes{} struct containing all the changes.

Examples

iex> import Elxvips
iex>
iex> from_file( "test/input.png" )
iex> |> png()
iex> |> to_bytes()
{:ok, %ImageBytes{}}
Link to this function

to_file(image, path)

Will save the image to a path on disk and return a new %ImageFile{} from the new path.

Examples

iex> import Elxvips
iex>
iex> from_file( "test/input.png" )
iex> |> png()
iex> |> to_file( "test/outping.png" )
{:ok, %ImageBytes{}}
Link to this function

webp(image, opts \\ [])

Will save the ImageFile in webp format to a specified path. Accepts quality and strip options. By default quality is set to 100, and strip to true.

Examples

iex> import Elxvips
iex>
iex> from_file( "/path/input.jpg" )
iex> |> webp( strip: true, quality: 72 )
iex  |> to_file( "/path/output.webp" )
{ :ok, %ImageFile{} }