Consolidate cover resize logic

Moves resizing out of the MusicBrainz namespace to Records - which
improves division of responsibilities, and removes double resizing
during import.
This commit is contained in:
Claudio Ortolina
2024-11-26 08:35:16 +00:00
parent 5cb2214922
commit f0212eeb6f
6 changed files with 32 additions and 26 deletions
+4 -4
View File
@@ -418,14 +418,14 @@ defmodule MusicBrainz.APIImpl do
end
def get_cover_art({:url, url}) do
with {:ok, cover_data} <- blob_get(url),
{:ok, thumb} = Vix.Vips.Operation.thumbnail_buffer(cover_data, 600) do
Vix.Vips.Image.write_to_buffer(thumb, ".jpg")
else
case blob_get(url) do
{:error, reason} ->
Logger.error("Failed to fetch cover art for #{url}, reason: #{inspect(reason)}")
{:error, :cover_not_available}
success ->
success
end
end