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

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

A WebP keeps its metadata in chunks of its own, `EXIF` and `XMP `,
which the `VP8X` header lists. These functions rewrite those chunks and
the header's flags, and copy every other chunk, the image and what
draws it (alpha, the colour profile, an animation's frames), byte for
byte.

  * `strip: :gps` - the Exif GPS directory, zeroed, and XMP's GPS
    properties.
  * `strip: {:keep, tags}` - Exif with only the tags named, and no XMP
    or chunk of another app's.
  * `put: %{artist: _, copyright: _, image_description: _}` - written
    into Exif. A simple WebP, which has no `VP8X` header, is given one,
    from its image's size.

`edit_file/3` reads only the metadata chunks into memory. A WebP 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_webp | :malformed | :malformed_exif
```

Why a WebP is refused.

# `edit`

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

The WebP 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 WebP 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`).

---

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