Infer.Image (Infer v0.1.0) View Source

Image type matchers based on the magic number

Link to this section Summary

Functions

Takes the binary file contents as arguments. Returns true if it's a avif.

Takes the binary file contents as arguments. Returns true if it's a bmp.

Takes the binary file contents as arguments. Returns true if it's a cr2.

Takes the binary file contents as arguments. Returns true if it's a gif.

Takes the binary file contents as arguments. Returns true if it's a heif.

Takes the binary file contents as arguments. Returns true if it's a ico.

Takes the binary file contents as arguments. Returns true if it's a jpeg.

Takes the binary file contents as arguments. Returns true if it's a jpeg2000.

Takes the binary file contents as arguments. Returns true if it's a jxr.

Takes the binary file contents as arguments. Returns true if it's a png.

Takes the binary file contents as arguments. Returns true if it's a psd.

Takes the binary file contents as arguments. Returns true if it's a tiff.

Takes the binary file contents as arguments. Returns true if it's a webp.

Link to this section Functions

Specs

is_avif(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a avif.

Examples

iex> binary = File.read!("test/images/sample.avif")
iex> Infer.Image.is_avif(binary)
true

iex> binary = File.read!("test/images/sample.heif")
iex> Infer.Image.is_avif(binary)
false

Specs

is_bmp(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a bmp.

Examples

iex> binary = File.read!("test/images/sample.bmp")
iex> Infer.Image.is_bmp(binary)
true

iex> binary = File.read!("test/images/sample.png")
iex> Infer.Image.is_bmp(binary)
false

Specs

is_cr2(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a cr2.

Examples

iex> binary = File.read!("test/images/sample.cr2")
iex> Infer.Image.is_cr2(binary)
true

iex> binary = File.read!("test/images/sample.tiff")
iex> Infer.Image.is_cr2(binary)
false

Specs

is_gif(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a gif.

Examples

iex> binary = File.read!("test/images/sample.gif")
iex> Infer.Image.is_gif(binary)
true

iex> binary = File.read!("test/images/sample.jpg")
iex> Infer.Image.is_gif(binary)
false

Specs

is_heif(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a heif.

Examples

iex> binary = File.read!("test/images/sample.heif")
iex> Infer.Image.is_heif(binary)
true

iex> binary = File.read!("test/images/sample.avif")
iex> Infer.Image.is_heif(binary)
false

Specs

is_ico(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a ico.

Examples

iex> binary = File.read!("test/images/sample.ico")
iex> Infer.Image.is_ico(binary)
true

iex> binary = File.read!("test/images/sample.png")
iex> Infer.Image.is_ico(binary)
false

Specs

is_jpeg(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a jpeg.

Examples

iex> binary = File.read!("test/images/sample.jpg")
iex> Infer.Image.is_jpeg(binary)
true

iex> binary = File.read!("test/images/sample.jp2")
iex> Infer.Image.is_jpeg(binary)
false

Specs

is_jpeg2000(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a jpeg2000.

Examples

iex> binary = File.read!("test/images/sample.jp2")
iex> Infer.Image.is_jpeg2000(binary)
true

iex> binary = File.read!("test/images/sample.jpg")
iex> Infer.Image.is_jpeg2000(binary)
false

Specs

is_jxr(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a jxr.

Examples

iex> binary = File.read!("test/images/sample.jxr")
iex> Infer.Image.is_jxr(binary)
true

iex> binary = File.read!("test/images/sample.png")
iex> Infer.Image.is_jxr(binary)
false

Specs

is_png(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a png.

Examples

iex> binary = File.read!("test/images/sample.png")
iex> Infer.Image.is_png(binary)
true

iex> binary = File.read!("test/images/sample.jpg")
iex> Infer.Image.is_png(binary)
false

Specs

is_psd(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a psd.

Examples

iex> binary = File.read!("test/images/sample.psd")
iex> Infer.Image.is_psd(binary)
true

iex> binary = File.read!("test/images/sample.png")
iex> Infer.Image.is_psd(binary)
false

Specs

is_tiff(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a tiff.

Examples

iex> binary = File.read!("test/images/sample.tiff")
iex> Infer.Image.is_tiff(binary)
true

iex> binary = File.read!("test/images/sample.cr2")
iex> Infer.Image.is_tiff(binary)
false

Specs

is_webp(binary()) :: boolean()

Takes the binary file contents as arguments. Returns true if it's a webp.

Examples

iex> binary = File.read!("test/images/sample.webp")
iex> Infer.Image.is_webp(binary)
true

iex> binary = File.read!("test/images/sample.gif")
iex> Infer.Image.is_webp(binary)
false