elxvips v0.0.3 Elxvips

Documentation for Elxvips.

Link to this section Summary

Functions

Converts %ImageFile{} to %ImageBytes{} for further processing.

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.

Same as jpg() but works with %ImageBytes{}.

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

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

Same as png() but works with %ImageBytes{}.

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 set the concurrency of libVips to a specified number. By default it will check for "VIPS_CONCURRENCY" environment variable, if none if found it will fallback to number of cpu cores.

Link to this section Functions

Converts %ImageFile{} to %ImageBytes{} for further processing.

Examples

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

get_image_sizes(path)

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

Examples

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

jpg(image_file, path, 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> Elxvips.open( "/path/input.png" )
iex> |> Elxvips.jpg( "/path/output.jpg", strip: true, quality: 72 ) 
{ :ok, %ImageFile{ :path => "/path/output.jpg", ... } }
Link to this function

jpg_bytes(image_bytes, opts \\ [])

Same as jpg() but works with %ImageBytes{}.

Examples

iex> Elxvips.open( "/path/input.png" )
iex> |> Elxvips.jpg_bytes( strip: true, quality: 72 ) 
{ :ok, %ImageBytes{ :bytes => [...] } }

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

Examples

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

png(image_file, path, opts \\ [])

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

Examples

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

png_bytes(image_bytes, opts \\ [])

Same as png() but works with %ImageBytes{}.

Examples

iex> Elxvips.open( "/path/input.jpg" )
iex> |> Elxvips.png_bytes( strip: true, quality: 72 ) 
{ :ok, %ImageBytes{ :bytes => [...] } }
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.

Note

All resizes are applied on image creation, when jpg or jpg_bytes or other format functions are called.

Examples

iex> Elxvips.open( "test/input.png" )
iex> |> Elxvips.resize( width: 300 )
{:ok, %ImageBytes{}}

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

set_concurrency(concurrency)

Will set the concurrency of libVips to a specified number. By default it will check for "VIPS_CONCURRENCY" environment variable, if none if found it will fallback to number of cpu cores.

Examples

iex> Elxvips.set_concurrency( 4 )
:ok