Infer.Image (Infer v0.2.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 jpeg2000.

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 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

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.avif?(binary)
true

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

Specs

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.bmp?(binary)
true

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

Specs

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.cr2?(binary)
true

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

Specs

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.gif?(binary)
true

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

Specs

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.heif?(binary)
true

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

Specs

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.ico?(binary)
true

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

Specs

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.jpeg2000?(binary)
true

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

Specs

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.jpeg?(binary)
true

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

Specs

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.jxr?(binary)
true

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

Specs

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.png?(binary)
true

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

Specs

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.psd?(binary)
true

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

Specs

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.tiff?(binary)
true

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

Specs

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.webp?(binary)
true

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