Fastimage v1.0.0-rc4 Fastimage View Source
Fastimage finds the dimensions/size or file type of a remote url, local image file or a binary object given the url, file path or binary itself respectively.
It streams the smallest amount of data necessary to ascertain the file size.
Supports “.bmp”, “.gif”, “.jpeg”, “.webp” or “.png” image types only.
Link to this section Summary
Types
:stream_timeout
- Applies to a url only. An override for the after:stream_timeout
field in theFastimage.Stream.Acc
struct which in turn determines the timeout in the processing of the hackney stream. By default the @default_stream_timeout is used inFastimage.Stream.Acc
Functions
Returns a %Fastimage{}
struct with information such as
type and dimensions. Accepts a source as a url, binary
object or file path
Returns a %Fastimage{}
struct with information such as
type and dimensions. Accepts a source as a url, binary
object or file path
Returns the dimensions of the image. Accepts a source as a url, binary object or file path
Returns the dimensions of the image. Accepts a source as a url, binary object or file path
Returns the type of image. Accepts a source as a url, binary object or file path
Returns the type of image. Accepts a source as a url, binary object or file path
Link to this section Types
fastimage_opts() :: [ stream_timeout: non_neg_integer(), max_error_retries: non_neg_integer(), max_redirect_retries: non_neg_integer() ]
:stream_timeout
- Applies to a url only. An override for the after:stream_timeout
field in theFastimage.Stream.Acc
struct which in turn determines the timeout in the processing of the hackney stream. By default the @default_stream_timeout is used inFastimage.Stream.Acc
.:max_error_retries
- Applies to a url only. An override for the:max_error_retries
field in theFastimage.Stream.Acc
struct which in turn determines the maximum number of retries that will be attempted before giving up and returning an error. By default the @default_max_error_retries is used inFastimage.Stream.Acc
.:max_redirect_retries
- Applies to a url only. An override for the:max_redirect_retries
field in theFastimage.Stream.Acc
struct which in turn determines the maximum number of redirects that will be attempted before giving up and returning an error. By default the @default_max_redirect_retries is used inFastimage.Stream.Acc
.
t() :: %Fastimage{ dimensions: Fastimage.Dimensions.t(), image_type: image_type() | nil, source: binary() | nil, source_type: source_type() | nil }
Link to this section Functions
info!(binary(), fastimage_opts()) :: Fastimage.t() | no_return()
Returns a %Fastimage{}
struct with information such as
type and dimensions. Accepts a source as a url, binary
object or file path.
Example
iex> Fastimage.info!("https://raw.githubusercontent.com/stephenmoloney/fastimage/master/priv/test.jpg")
%Fastimage{
dimensions: %Fastimage.Dimensions{height: 142, width: 283},
image_type: :jpeg,
source: "https://raw.githubusercontent.com/stephenmoloney/fastimage/master/priv/test.jpg",
source_type: :url
}
info(binary(), fastimage_opts()) :: {:ok, Fastimage.t()} | {:error, Fastimage.Error.t()}
Returns a %Fastimage{}
struct with information such as
type and dimensions. Accepts a source as a url, binary
object or file path.
Example
iex> Fastimage.info("https://raw.githubusercontent.com/stephenmoloney/fastimage/master/priv/test.jpg")
{:ok,
%Fastimage{
dimensions: %Fastimage.Dimensions{height: 142, width: 283},
image_type: :jpeg,
source: "https://raw.githubusercontent.com/stephenmoloney/fastimage/master/priv/test.jpg",
source_type: :url
}}
size!(binary(), fastimage_opts()) :: Fastimage.Dimensions.t() | no_return()
Returns the dimensions of the image. Accepts a source as a url, binary object or file path.
Example
iex> Fastimage.size!("https://raw.githubusercontent.com/stephenmoloney/fastimage/master/priv/test.jpg")
%Fastimage.Dimensions{height: 142, width: 283}
size(binary(), fastimage_opts()) :: {:ok, Fastimage.Dimensions.t()} | {:error, Fastimage.Error.t()}
Returns the dimensions of the image. Accepts a source as a url, binary object or file path.
Example
iex> Fastimage.size("https://raw.githubusercontent.com/stephenmoloney/fastimage/master/priv/test.jpg")
{:ok, %Fastimage.Dimensions{height: 142, width: 283}}
type!(binary(), fastimage_opts()) :: image_type() | no_return()
Returns the type of image. Accepts a source as a url, binary object or file path.
Example
iex> Fastimage.type!("https://raw.githubusercontent.com/stephenmoloney/fastimage/master/priv/test.jpg")
:jpeg
type(binary(), fastimage_opts()) :: {:ok, image_type()} | {:error, Fastimage.Error.t()}
Returns the type of image. Accepts a source as a url, binary object or file path.
Example
iex> Fastimage.type("https://raw.githubusercontent.com/stephenmoloney/fastimage/master/priv/test.jpg")
{:ok, :jpeg}