ExPng.Image (ExPng v1.0.0)
The primary API module for ExPng
, ExPng.Image
provides functions for
reading, editing, and saving images.
Link to this section Summary
Functions
Attempts to decode a PNG file into an ExPng.Image
and returns a success
tuple {:ok, image}
or an error tuple explaining the encountered error.
Constructs a new image from the provided 2-dimensional list of pixels
Returns a blank (opaque white) image with the provided width and height
Writes the image
to disk at filename
using the provided
encoding_options
.
Returns a list of unique pixels values used in image
.
Link to this section Types
canvas()
Specs
canvas() :: [row(), ...]
error()
Specs
filename()
Specs
filename() :: String.t()
row()
Specs
row() :: [ExPng.Color.t(), ...]
success()
Specs
success() :: {:ok, t()}
Specs
t() :: %ExPng.Image{ height: pos_integer(), pixels: ExPng.maybe(canvas()), raw_data: ExPng.maybe(ExPng.RawData.t()), width: pos_integer() }
Link to this section Functions
at(image, coordinates)
clear(image, coordinates)
draw(image, coordinates, color)
erase(image)
from_file(filename)
Specs
Attempts to decode a PNG file into an ExPng.Image
and returns a success
tuple {:ok, image}
or an error tuple explaining the encountered error.
ExPng.Image.from_file("adorable_kittens.png")
{:ok, %ExPng.Image{ ... }
ExPng.Image.from_file("doesnt_exist.png")
{:error, :enoent, "doesnt_exist.png"}
line(image, coordinates0, coordinates1, color \\ ExPng.Color.black())
new(pixels)
Specs
Constructs a new image from the provided 2-dimensional list of pixels
new(width, height)
Specs
new(pos_integer(), pos_integer()) :: t()
Returns a blank (opaque white) image with the provided width and height
to_file(image, filename, encoding_options \\ [])
Specs
to_file(t(), filename(), ExPng.maybe(keyword())) :: {:ok, filename()}
Writes the image
to disk at filename
using the provided
encoding_options
.
Encoding options can be:
- interlace: whether or not the image in encoding with Adam7 interlacing.
- defaults to
false
- defaults to
- filter: the filtering algorithm to use. Can be one of
ExPng.Image.Filtering.{none, sub, up, average, paeth}
- defaults to
up
- defaults to
- compression: the compression level for the zlib compression algorithm to use. Can be an integer between 0 (no compression) and 9 (max compression)
- defaults to 6
unique_pixels(image)
Specs
unique_pixels(t()) :: [ExPng.Color.t()]
Returns a list of unique pixels values used in image
.