elxvips v0.0.5 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 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.
Link to this section Functions
from_bytes(bytes)
Will create an %ImageByte{} struct from bitstring or byte list. This struct will be used for further processing.
Examples
iex> file = File.open!( "/path/input.png" )
iex> bytes = IO.binread( file, :all )
iex> Elxvips.from_bytes( bytes )
%ImageBytes{}
from_file(path)
Will create an %ImageFile{} struct from path. This struct will be used for further processing.
Examples
iex> Elxvips.from_file( "/path/input.png" )
%ImageFile{}
get_image_sizes(path)
Returns dimensions of the specified image, works with a image path or bytes.
Examples
iex> Elxvips.from_file( "test/input.png" )
iex> |> Elxvips.get_image_sizes()
{:ok, [640, 486]}
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> Elxvips.open( "/path/input.png" )
iex> |> Elxvips.jpg( "/path/output.jpg", strip: true, quality: 72 )
{ :ok, %ImageFile{ :path => "/path/output.jpg", ... } }
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> Elxvips.open( "/path/input.jpg" )
iex> |> Elxvips.png( "/path/output.png", strip: true, quality: 72 )
{ :ok, %ImageFile{ :path => "/path/output.png", ... } }
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> Elxvips.from_file( "test/input.png" )
iex> |> Elxvips.resize( width: 300 )
{:ok, %ImageBytes{}}
iex> Elxvips.from_file( "test/input.png" )
iex> |> Elxvips.resize()
{:ok, %ImageBytes{}}
set_concurrency(concurrency)
to_bytes(image)
Will create a new %ImageBytes{} struct containing all the changes.
Examples
iex> Elxvips.from_file( "test/input.png" )
iex> |> Elxvips.png()
iex> |> Elxvips.to_bytes()
{:ok, %ImageBytes{}}
to_file(image, path)
Will save the image to a path on disk and return a new %ImageFile{} from the new path.
Examples
iex> Elxvips.from_file( "test/input.png" )
iex> |> Elxvips.png()
iex> |> Elxvips.to_file( "test/outping.png" )
{:ok, %ImageBytes{}}