Elxvips (elxvips v0.1.4) View Source
Documentation for Elxvips
.
Link to this section Summary
Functions
Will save the ImageFile in avif(AV1) format to a specified path. Accepts quality and strip options. By default quality is set to 100
Sets the background of the image in case there is a transparent background. Accepts a empty list, or a list of length 2 or 3.
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.
Will create an %ImageFile{} struct from a pdf path. This struct will be used for further processing. Accepts the following options
Will create an %ImageByte{} struct from pdf bitstring or byte list. This struct will be used for further processing. Accepts the following options
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
Will save the ImageFile in avif(AV1) format to a specified path. Accepts quality and strip options. By default quality is set to 100
Examples
iex> import Elxvips
iex>
iex> from_file( "/path/input.jpg" )
iex> |> avif( quality: 72 )
iex |> to_file( "/path/output.avif" )
{ :ok, %ImageFile{} }
Sets the background of the image in case there is a transparent background. Accepts a empty list, or a list of length 2 or 3.
Examples
iex> import Elxvips
iex>
iex> from_file( "test/input.png" )
iex |> jpg()
iex> |> background( [ 255, 0, 0 ] ) # red background
iex |> to_file( "test/output.jpg" )
{:ok, %ImageBytes{}}
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{}
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{}
Will create an %ImageFile{} struct from a pdf path. This struct will be used for further processing. Accepts the following options:
:page
- page number to extract from pdf, default is 0:n
- number of pages to extract from pdf, default is 1
Examples
iex> import Elxvips
iex>
iex> from_pdf( "/path/input.pdf", page: 0, n: 2 )
%ImageFile{}
Will create an %ImageByte{} struct from pdf bitstring or byte list. This struct will be used for further processing. Accepts the following options:
:page
- page number to extract from pdf, default is 0:n
- number of pages to extract from pdf, default is 1
Examples
iex> import Elxvips
iex>
iex> file = File.open!( "/path/input.pdf" )
iex> bytes = IO.binread( file, :all )
iex> from_pdf_bytes( bytes, page: 0, n: 2 )
%ImageBytes{}
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}
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]}
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{} }
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{} }
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{}}
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{}}
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{}}
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{} }