View Source Infer.Image (Infer v0.2.5)

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

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

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

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

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

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

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

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

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

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

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

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

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

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