Vix.Vips.Image (vix v0.2.1) View Source

Vips Image

Link to this section Summary

Types

t()

Represents an instance of libvips image

Functions

Get bands

Get filename

Get all image header field names.

Get image header value.

Get image header value as string.

Get height

Get mode

Get n_pages

Opens path for reading, returns an instance of Vix.Vips.Image.t/0

Make a VipsImage which, when written to, will create a temporary file on disc.

Get offset

Get orientation

Get page_height

Get scale

Get width

Write vips_image to a file.

Get xoffset

Get xres

Get yoffset

Get yres

Link to this section Types

Specs

t()

Represents an instance of libvips image

Link to this section Functions

Specs

bands(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get bands

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-bands

Specs

filename(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get filename

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-filename

Link to this function

header_field_names(vips_image)

View Source

Specs

header_field_names(Vix.Vips.Image.t()) :: {:ok, [String.t()]} | {:error, term()}

Get all image header field names.

See https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-fields for more details

Link to this function

header_value(vips_image, name)

View Source

Specs

header_value(Vix.Vips.Image.t(), String.t()) ::
  {:ok, integer() | float() | String.t() | [integer()]} | {:error, term()}

Get image header value.

This is a generic function to get header value.

Casts the value to appropriate type. Currently it only supports values of type integer, float, string and list of integer values. Use Vix.Vips.Image.header_value_as_string/2 to get string representation of any header value.

{:ok, width} = Image.header_value(vips_image, "width")
Link to this function

header_value_as_string(vips_image, name)

View Source

Specs

header_value_as_string(Vix.Vips.Image.t(), String.t()) ::
  {:ok, String.t()} | {:error, term()}

Get image header value as string.

This is generic method to get string representation of a header value. If value is VipsBlob, then it returns base64 encoded data.

See: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-as-string

Specs

height(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get height

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-height

Specs

mode(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get mode

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-mode

Specs

n_pages(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get n_pages

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-n-pages

Specs

new_from_file(String.t()) :: {:ok, Vix.Vips.Image.t()} | {:error, term()}

Opens path for reading, returns an instance of Vix.Vips.Image.t/0

It can load files in many image formats, including VIPS, TIFF, PNG, JPEG, FITS, Matlab, OpenEXR, CSV, WebP, Radiance, RAW, PPM and others.

Load options may be appended to filename as "[name=value,...]". For example:

Image.new_from_file("fred.jpg[shrink=2]")

Will open "fred.jpg", downsampling by a factor of two.

The full set of options available depend upon the load operation that will be executed. Try something like:

$ vips jpegload

at the command-line to see a summary of the available options for the JPEG loader.

Loading is fast: only enough of the image is loaded to be able to fill out the header. Pixels will only be decompressed when they are needed.

Link to this function

new_matrix_from_array(width, height, list, optional \\ [])

View Source

Specs

new_matrix_from_array(integer(), integer(), [list()], keyword()) ::
  :ok | {:error, term()}

Make a VipsImage from list.

This convenience function makes an image which is a matrix: a one-band VIPS_FORMAT_DOUBLE image held in memory. Useful for vips operations such as conv.

mask = Image.new_matrix_from_array(3, 3, [[0, 1, 0], [1, 1, 1], [0, 1, 0]])

Optional

  • scale - Default: 1
  • offset - Default: 0

Specs

new_temp_file(String.t()) :: :ok | {:error, term()}

Make a VipsImage which, when written to, will create a temporary file on disc.

The file will be automatically deleted when the image is destroyed. format is something like "%s.v" for a vips file.

The file is created in the temporary directory. This is set with the environment variable TMPDIR. If this is not set, then on Unix systems, vips will default to /tmp. On Windows, vips uses GetTempPath() to find the temporary directory.

vips_image = Image.new_temp_file("%s.v")

Specs

offset(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get offset

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-offset

Specs

orientation(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get orientation

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-orientation

Specs

page_height(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get page_height

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-page-height

Specs

scale(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get scale

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-scale

Specs

width(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get width

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-width

Link to this function

write_to_file(vips_image, path)

View Source

Specs

write_to_file(Vix.Vips.Image.t(), String.t()) :: :ok | {:error, term()}

Write vips_image to a file.

Save options may be encoded in the filename or given as a hash. For example:

Image.write_to_file(vips_image, "fred.jpg[Q=90]")

A saver is selected based on path. The full set of save options depend on the selected saver. Try something like:

$ vips jpegsave

at the command-line to see all the available options for JPEG save.

Specs

xoffset(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get xoffset

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-xoffset

Specs

xres(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get xres

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-xres

Specs

yoffset(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get yoffset

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-yoffset

Specs

yres(Vix.Vips.Image.t()) :: {:ok, term()} | {:error, term()}

Get yres

see: https://libvips.github.io/libvips/API/current/libvips-header.html#vips-image-get-yres