mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-31 00:37:45 +02:00
Undoing webp fail
This commit is contained in:
parent
dfb5314d93
commit
c692acf1e9
8 changed files with 6 additions and 37 deletions
|
@ -242,7 +242,7 @@
|
||||||
"Groupings": [
|
"Groupings": [
|
||||||
"solo",
|
"solo",
|
||||||
"duo",
|
"duo",
|
||||||
"trio","",
|
"trio",
|
||||||
"solo focus",
|
"solo focus",
|
||||||
"duo focus",
|
"duo focus",
|
||||||
"trio focus",
|
"trio focus",
|
||||||
|
|
|
@ -9,7 +9,6 @@ defmodule Philomena.Analyzers do
|
||||||
alias Philomena.Analyzers.Jpeg
|
alias Philomena.Analyzers.Jpeg
|
||||||
alias Philomena.Analyzers.Png
|
alias Philomena.Analyzers.Png
|
||||||
alias Philomena.Analyzers.Svg
|
alias Philomena.Analyzers.Svg
|
||||||
alias Philomena.Analyzers.Webp
|
|
||||||
alias Philomena.Analyzers.Webm
|
alias Philomena.Analyzers.Webm
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -34,7 +33,6 @@ defmodule Philomena.Analyzers do
|
||||||
def analyzer("image/jpeg"), do: {:ok, Jpeg}
|
def analyzer("image/jpeg"), do: {:ok, Jpeg}
|
||||||
def analyzer("image/png"), do: {:ok, Png}
|
def analyzer("image/png"), do: {:ok, Png}
|
||||||
def analyzer("image/svg+xml"), do: {:ok, Svg}
|
def analyzer("image/svg+xml"), do: {:ok, Svg}
|
||||||
def analyzer("image/webp"), do: {:ok, Webp}
|
|
||||||
def analyzer("video/webm"), do: {:ok, Webm}
|
def analyzer("video/webm"), do: {:ok, Webm}
|
||||||
def analyzer(_content_type), do: :error
|
def analyzer(_content_type), do: :error
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
defmodule Philomena.Analyzers.Jpeg do
|
|
||||||
def analyze(file) do
|
|
||||||
stats = stats(file)
|
|
||||||
|
|
||||||
%{
|
|
||||||
extension: "jpg",
|
|
||||||
mime_type: "image/webp",
|
|
||||||
animated?: false,
|
|
||||||
duration: stats.duration,
|
|
||||||
dimensions: stats.dimensions
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
defp stats(file) do
|
|
||||||
case System.cmd("mediastat", [file]) do
|
|
||||||
{output, 0} ->
|
|
||||||
[_size, _frames, width, height, num, den] =
|
|
||||||
output
|
|
||||||
|> String.trim()
|
|
||||||
|> String.split(" ")
|
|
||||||
|> Enum.map(&String.to_integer/1)
|
|
||||||
|
|
||||||
%{dimensions: {width, height}, duration: num / den}
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
%{dimensions: {0, 0}, duration: 0.0}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -166,7 +166,7 @@ defmodule Philomena.Images.Image do
|
||||||
|> validate_length(:image_name, max: 255, count: :bytes)
|
|> validate_length(:image_name, max: 255, count: :bytes)
|
||||||
|> validate_inclusion(
|
|> validate_inclusion(
|
||||||
:image_mime_type,
|
:image_mime_type,
|
||||||
~W(image/gif image/jpeg image/png image/svg+xml image/webp video/webm),
|
~W(image/gif image/jpeg image/png image/svg+xml video/webm),
|
||||||
message: "(#{attrs["image_mime_type"]}) is invalid"
|
message: "(#{attrs["image_mime_type"]}) is invalid"
|
||||||
)
|
)
|
||||||
|> check_dimensions()
|
|> check_dimensions()
|
||||||
|
|
|
@ -30,7 +30,7 @@ defmodule Philomena.Mime do
|
||||||
def true_mime("audio/webm"), do: {:ok, "video/webm"}
|
def true_mime("audio/webm"), do: {:ok, "video/webm"}
|
||||||
|
|
||||||
def true_mime(mime)
|
def true_mime(mime)
|
||||||
when mime in ~W(image/gif image/jpeg image/png image/webp image/svg+xml video/webm),
|
when mime in ~W(image/gif image/jpeg image/png image/svg+xml video/webm),
|
||||||
do: {:ok, mime}
|
do: {:ok, mime}
|
||||||
|
|
||||||
def true_mime(mime), do: {:unsupported_mime, mime}
|
def true_mime(mime), do: {:unsupported_mime, mime}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule Philomena.Scrapers.Raw do
|
defmodule Philomena.Scrapers.Raw do
|
||||||
@mime_types ["image/gif", "image/jpeg", "image/png", "image/svg", "image/webp", "image/svg+xml", "video/webm"]
|
@mime_types ["image/gif", "image/jpeg", "image/png", "image/svg", "image/svg+xml", "video/webm"]
|
||||||
|
|
||||||
@spec can_handle?(URI.t(), String.t()) :: true | false
|
@spec can_handle?(URI.t(), String.t()) :: true | false
|
||||||
def can_handle?(_uri, url) do
|
def can_handle?(_uri, url) do
|
||||||
|
|
|
@ -118,7 +118,7 @@ defmodule Philomena.Tags.Tag do
|
||||||
tag
|
tag
|
||||||
|> cast(attrs, [:image, :image_format, :image_mime_type, :uploaded_image])
|
|> cast(attrs, [:image, :image_format, :image_mime_type, :uploaded_image])
|
||||||
|> validate_required([:image, :image_format, :image_mime_type])
|
|> validate_required([:image, :image_format, :image_mime_type])
|
||||||
|> validate_inclusion(:image_mime_type, ~W(image/gif image/jpeg image/png image/webp image/svg+xml))
|
|> validate_inclusion(:image_mime_type, ~W(image/gif image/jpeg image/png image/svg+xml))
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_image_changeset(tag) do
|
def remove_image_changeset(tag) do
|
||||||
|
|
|
@ -3,7 +3,7 @@ defmodule PhilomenaWeb.DuplicateReportView do
|
||||||
|
|
||||||
alias PhilomenaWeb.ImageView
|
alias PhilomenaWeb.ImageView
|
||||||
|
|
||||||
@formats_order ~W(video/webm image/svg+xml image/png image/gif image/jpeg image/webp other)
|
@formats_order ~W(video/webm image/svg+xml image/png image/gif image/jpeg other)
|
||||||
|
|
||||||
def comparison_url(conn, image),
|
def comparison_url(conn, image),
|
||||||
do: ImageView.thumb_url(image, can?(conn, :show, image), :full)
|
do: ImageView.thumb_url(image, can?(conn, :show, image), :full)
|
||||||
|
|
Loading…
Add table
Reference in a new issue