mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
recalculate size on processing (derpibooru/philomena#206)
This commit is contained in:
parent
02cbecb193
commit
a955a67b24
2 changed files with 7 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue