Avoid unnecessary module attributes

This commit is contained in:
Claudio Ortolina
2025-02-20 15:08:39 +00:00
parent ab2d1726bf
commit 26297a8bb1
+12 -11
View File
@@ -1,17 +1,18 @@
defmodule MusicLibrary.Records.Cover do
alias Vix.Vips.{Image, Operation}
fallback_path = Application.app_dir(:music_library, ["priv", "cover-not-found.jpg"])
fallback_data = File.read!(fallback_path)
@external_resource fallback_path
@size 600
@fallback_path Application.app_dir(:music_library, ["priv", "cover-not-found.jpg"])
@external_resource @fallback_path
@fallback_data File.read!(@fallback_path)
def fallback_data, do: @fallback_data
def fallback_data, do: unquote(fallback_data)
def resize(cover_data, size \\ @size) do
{:ok, thumb} = Vix.Vips.Operation.thumbnail_buffer(cover_data, size)
Vix.Vips.Image.write_to_buffer(thumb, ".jpg")
{:ok, thumb} = Operation.thumbnail_buffer(cover_data, size)
Image.write_to_buffer(thumb, ".jpg")
end
def hash(cover_data) do
@@ -19,8 +20,8 @@ defmodule MusicLibrary.Records.Cover do
end
def correct_size?(cover_data) do
{:ok, image} = Vix.Vips.Image.new_from_buffer(cover_data)
{:ok, image} = Image.new_from_buffer(cover_data)
Vix.Vips.Image.width(image) == @size
Image.width(image) == @size
end
end