# `Storehouse.Image.PNG`
[🔗](https://github.com/hattoriai/storehouse/blob/v0.2.0/lib/storehouse/image/png.ex#L1)

Edits the metadata inside a PNG without re-encoding it, as
`Storehouse.Image.JPEG` does a JPEG's: the same changes, the same tags.

A PNG keeps its metadata in chunks of their own: Exif (`eXIf`), XMP and
text (`iTXt`, `tEXt`, `zTXt`), the time (`tIME`). These functions
rewrite those chunks, each with its checksum, and copy every other one,
the image data and what draws it (palette, transparency, colour
profile, an APNG's frames), byte for byte.

  * `strip: :gps` - the Exif GPS directory, zeroed, and XMP's GPS
    properties. The "Raw profile type" text chunks ImageMagick writes,
    Exif and XMP again in hexadecimal, go too.
  * `strip: {:keep, tags}` - Exif with only the tags named, the text
    chunks of those tags (`Author`, `Copyright`, `Description`), and no
    other text, XMP or time.
  * `put: %{artist: _, copyright: _, image_description: _}` - written
    into Exif, and as the text chunks `Author`, `Copyright` and
    `Description` that PNG readers show, in place of any before them.

`edit_file/3` reads only the metadata chunks into memory. A PNG whose
chunks cannot be read is refused with `{:error, :malformed}`, one whose
Exif cannot be read with `{:error, :malformed_exif}`.

# `reason`

```elixir
@type reason() :: :not_png | :malformed | :malformed_exif
```

Why a PNG is refused.

# `edit`

```elixir
@spec edit(binary(), Storehouse.Image.MetadataEditor.changes()) ::
  {:ok, binary()} | {:error, reason()}
```

The PNG with `changes` made (`Storehouse.Image.MetadataEditor`): `:strip`, then `:put`.

# `edit_file`

```elixir
@spec edit_file(Path.t(), Path.t(), Storehouse.Image.MetadataEditor.changes()) ::
  :ok | :unchanged | {:error, reason() | File.posix()}
```

The PNG at `from`, with `changes` made (as `edit/2`), written to `to`,
with only its metadata in memory. `:unchanged` when there is nothing to
change, and `to` is not written.

# `tags`

```elixir
@spec tags(binary()) :: {:ok, map()} | {:error, reason()}
```

The named tags its Exif has (`Storehouse.Image.JPEG.tags/1`), and the text
chunks `Author`, `Copyright` and `Description` as `:artist`,
`:copyright` and `:image_description` where Exif has none.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
