Kino Vix Demo
Section
alias Vix.Vips.Image
alias Vix.Vips.Operation
defmodule Helper do
def download(url) do
{:ok, {_, _, body}} = :httpc.request(:get, {url, []}, [], [])
IO.iodata_to_binary(body)
end
end
{:ok, starry_night} =
Helper.download(
"https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg/757px-Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg"
)
|> Image.new_from_buffer()
{:ok, sunflower} =
Helper.download(
"https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Vincent_van_Gogh_-_Sunflowers_-_VGM_F458.jpg/457px-Vincent_van_Gogh_-_Sunflowers_-_VGM_F458.jpg"
)
|> Image.new_from_buffer()
{text, _flags} =
Vix.Vips.Operation.text!("SUNFLOWER",
dpi: 400,
rgba: true,
align: :VIPS_ALIGN_HIGH
)
text
Kino.Layout.grid([starry_night, sunflower], columns: 1)
composite = Vix.Vips.Operation.composite2!(text, starry_night, :VIPS_BLEND_MODE_ATOP)