diff --git a/lib/philomena/images/image.ex b/lib/philomena/images/image.ex index 805267ff..31d622b3 100644 --- a/lib/philomena/images/image.ex +++ b/lib/philomena/images/image.ex @@ -195,13 +195,13 @@ defmodule Philomena.Images.Image do def thumbnail_changeset(image, attrs) do image - |> cast(attrs, [:image_sha512_hash, :image_size]) + |> cast(attrs, [:image_sha512_hash, :image_size, :image_width, :image_height]) |> change(thumbnails_generated: true, duplication_checked: true) end def process_changeset(image, attrs) do image - |> cast(attrs, [:image_sha512_hash, :image_size]) + |> cast(attrs, [:image_sha512_hash, :image_size, :image_width, :image_height]) |> change(processed: true) end diff --git a/lib/philomena/images/thumbnailer.ex b/lib/philomena/images/thumbnailer.ex index 46ea318b..5540a987 100644 --- a/lib/philomena/images/thumbnailer.ex +++ b/lib/philomena/images/thumbnailer.ex @@ -57,10 +57,14 @@ defmodule Philomena.Images.Thumbnailer do do: DuplicateReports.generate_reports(image) defp recompute_meta(image, file, changeset_fn) do + {:ok, %{dimensions: {width, height}}} = Analyzers.analyze(file) + image |> changeset_fn.(%{ "image_sha512_hash" => Sha512.file(file), - "image_size" => File.stat!(file).size + "image_size" => File.stat!(file).size, + "image_width" => width, + "image_height" => height }) |> Repo.update!() end