Fastimage v1.0.0-rc1 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.
Link to this section Summary
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
t() :: %Fastimage{ dimensions: Fastimage.Dimensions.t(), image_type: image_type() | nil, source: binary() | nil, source_type: source_type() | nil }
Link to this section Functions
Returns a %Fastimage{}
struct with information such as
type and dimensions. Accepts a source as a url, binary
object or file path.
Supports “.bmp”, “.gif”, “.jpeg” or “.png” image types only.
Options
: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
.
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
}}
Returns a %Fastimage{}
struct with information such as
type and dimensions. Accepts a source as a url, binary
object or file path.
Supports “.bmp”, “.gif”, “.jpeg” or “.png” image types only.
Options - see info/1
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
}
Returns the dimensions of the image. Accepts a source as a url, binary object or file path.
Supports “.bmp”, “.gif”, “.jpeg” or “.png” image types only.
Options
: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
.
Example
iex> Fastimage.size("https://raw.githubusercontent.com/stephenmoloney/fastimage/master/priv/test.jpg")
{:ok, %Fastimage.Dimensions{height: 142, width: 283}}
Returns the dimensions of the image. Accepts a source as a url, binary object or file path.
Supports “.bmp”, “.gif”, “.jpeg” or “.png” image types only.
Options - see size/1
Example
iex> Fastimage.size!("https://raw.githubusercontent.com/stephenmoloney/fastimage/master/priv/test.jpg")
%Fastimage.Dimensions{height: 142, width: 283}
Returns the type of image. Accepts a source as a url, binary object or file path.
Supports “.bmp”, “.gif”, “.jpeg” or “.png” image types only.
Options
: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
.
Example
iex> Fastimage.type("https://raw.githubusercontent.com/stephenmoloney/fastimage/master/priv/test.jpg")
{:ok, :jpeg}
Returns the type of image. Accepts a source as a url, binary object or file path.
Supports “.bmp”, “.gif”, “.jpeg” or “.png” image types only.
Options - see type/1
Example
iex> Fastimage.type!("https://raw.githubusercontent.com/stephenmoloney/fastimage/master/priv/test.jpg")
:jpeg