From 2026716c44c76375ae838e7d8f8e3bdb0940aaaf Mon Sep 17 00:00:00 2001 From: Nathan Long Date: Wed, 20 Mar 2024 15:35:41 -0400 Subject: [PATCH] Expand example on thumbnailing --- guides/thumbnailing.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/guides/thumbnailing.md b/guides/thumbnailing.md index 94b2986..1ed1522 100644 --- a/guides/thumbnailing.md +++ b/guides/thumbnailing.md @@ -43,6 +43,23 @@ } +Basic code: + +```elixir +iex> original_raw = File.read!("/path/to_original.jpg"); nil +nil +iex> {:ok, original} = Image.from_binary(original_raw) +{:ok, %Vix.Vips.Image{ref: #Reference<0.4099923103.164495390.164069>}} +iex> {:ok, thumbnail} = Image.thumbnail(original, 200) +{:ok, %Vix.Vips.Image{ref: #Reference<0.4099923103.164495390.164078>}} +iex> Image.write(thumbnail, "/tmp/thumbnail.png") +{:ok, %Vix.Vips.Image{ref: #Reference<0.4099923103.164495390.164078>}} +iex> Image.write(thumbnail, "/path/to_thumbnail.png") +{:ok, %Vix.Vips.Image{ref: #Reference<0.4099923103.164495390.164078>}} +``` + +Examples: +