Support blurhash

This commit is contained in:
Alex Gleason 2021-05-14 08:38:23 -05:00
commit 543e9402d6
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
5 changed files with 19 additions and 2 deletions

View file

@ -23,6 +23,7 @@ defmodule Pleroma.Upload.Filter.SetMeta do
upload
|> Map.put(:width, image.width)
|> Map.put(:height, image.height)
|> Map.put(:blurhash, get_blurhash(file))
{:ok, :filtered, upload}
rescue
@ -33,4 +34,12 @@ defmodule Pleroma.Upload.Filter.SetMeta do
end
def filter(_), do: {:ok, :noop}
defp get_blurhash(file) do
with {:ok, blurhash} <- :eblurhash.magick(file) do
blurhash
else
_ -> nil
end
end
end