KritaEx (KritaEx v0.1.1)

View Source

Provides functions to extract embedded images from Krita .kra files

Summary

Functions

Extracts the embedded png to a specified location

Aliased to read_png/2 with raw: false

Reads the embedded png in binary format

Aliased to valid_kra?/2 with raw: false

Verifies that the supplied .kra is valid

Functions

extract_png(kra, out_path, options \\ [])

Extracts the embedded png to a specified location

Parameters

  • kra: Path to .kra file or binary content (use of raw is required to use binary)
  • out_path: Output filepath
  • options:
    • raw: expect binary input (default false)
    • create_dirs: create output directories (default true)

Returns :ok or {:error, reason}.

Examples

iex(1)> KritaEx.extract_png("test/files/test.kra", "tmp/output.png")
:ok

iex(2)> KritaEx.extract_png("idontexist.kra", "tmp/output.png")
{:error, {:failed_read, :enoent}}

read_png(kra)

Aliased to read_png/2 with raw: false

read_png(kra, list)

Reads the embedded png in binary format

Parameters

  • kra: Path to .kra file or file contents (use of raw is required to use binary)
  • options:
    • raw: expect binary input (default: false, see read_png/1)

Examples

KritaEx.read_png("test/files/test.kra")
{:ok,
  <<137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 64, 0,
    0, 0, 64, 8, 6, 0, 0, 0, 170, 105, 113, 222, 0, 0, 0, 9, 112, 72, 89, 115, 0,
    0, 46, 35, 0, 0, 46, ...>>}

valid_kra?(kra)

Aliased to valid_kra?/2 with raw: false

valid_kra?(kra, list)

Verifies that the supplied .kra is valid

Parameters

  • kra: Path to .kra file or file contents (use of raw is required to use binary)
  • options:

Returns true or false

Examples

iex(1)> KritaEx.valid_kra?("test/files/test.kra")
true

iex(2)> KritaEx.valid_kra?("test/files/invalid.kra")
false