mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
fix svg previewing
This commit is contained in:
parent
64428907f5
commit
91ebd70966
1 changed files with 10 additions and 6 deletions
|
@ -1,12 +1,12 @@
|
|||
defmodule Philomena.Processors.Svg do
|
||||
alias Philomena.Intensities
|
||||
|
||||
def process(_analysis, file, versions) do
|
||||
def process(analysis, file, versions) do
|
||||
preview = preview(file)
|
||||
|
||||
{:ok, intensities} = Intensities.file(preview)
|
||||
|
||||
scaled = Enum.flat_map(versions, &scale_if_smaller(file, preview, &1))
|
||||
scaled = Enum.flat_map(versions, &scale_if_smaller(file, analysis.dimensions, preview, &1))
|
||||
|
||||
%{
|
||||
intensities: intensities,
|
||||
|
@ -29,14 +29,18 @@ defmodule Philomena.Processors.Svg do
|
|||
preview
|
||||
end
|
||||
|
||||
defp scale_if_smaller(_file, preview, {:full, _target_dim}) do
|
||||
defp scale_if_smaller(_file, _dimensions, preview, {:full, _target_dim}) do
|
||||
[{:symlink_original, "full.svg"}, {:copy, preview, "full.png"}]
|
||||
end
|
||||
|
||||
defp scale_if_smaller(_file, preview, {thumb_name, {target_width, target_height}}) do
|
||||
scaled = scale(preview, {target_width, target_height})
|
||||
defp scale_if_smaller(_file, {width, height}, preview, {thumb_name, {target_width, target_height}}) do
|
||||
if width > target_width or height > target_height do
|
||||
scaled = scale(preview, {target_width, target_height})
|
||||
|
||||
[{:copy, scaled, "#{thumb_name}.png"}]
|
||||
[{:copy, scaled, "#{thumb_name}.png"}]
|
||||
else
|
||||
[{:copy, preview, "#{thumb_name}.png"}]
|
||||
end
|
||||
end
|
||||
|
||||
defp scale(preview, {width, height}) do
|
||||
|
|
Loading…
Reference in a new issue