mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-19 11:29:17 +00:00
Fix uploading webp image files when Exiftool Upload Filter is enabled
This commit is contained in:
parent
c5434dbefc
commit
fa347b9c2f
|
@ -138,6 +138,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Fix whole_word always returning false on filter get requests
|
- Fix whole_word always returning false on filter get requests
|
||||||
- Migrations not working on OTP releases if the database was connected over ssl
|
- Migrations not working on OTP releases if the database was connected over ssl
|
||||||
- Fix relay following
|
- Fix relay following
|
||||||
|
- Fixed uploading webp images when the Exiftool Upload Filter is enabled
|
||||||
|
|
||||||
## [2.0.7] - 2020-06-13
|
## [2.0.7] - 2020-06-13
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,20 @@ defmodule Pleroma.Upload.Filter.Exiftool do
|
||||||
@behaviour Pleroma.Upload.Filter
|
@behaviour Pleroma.Upload.Filter
|
||||||
|
|
||||||
@spec filter(Pleroma.Upload.t()) :: :ok | {:error, String.t()}
|
@spec filter(Pleroma.Upload.t()) :: :ok | {:error, String.t()}
|
||||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
def filter(%Pleroma.Upload{name: file, tempfile: path, content_type: "image" <> _}) do
|
||||||
|
# webp is not compatible with exiftool at this time
|
||||||
|
if Regex.match?(~r/\.(webp)$/i, file) do
|
||||||
|
:ok
|
||||||
|
else
|
||||||
|
strip_exif(path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter(_), do: :ok
|
||||||
|
|
||||||
|
defp strip_exif(path) do
|
||||||
try do
|
try do
|
||||||
case System.cmd("exiftool", ["-overwrite_original", "-gps:all=", file], parallelism: true) do
|
case System.cmd("exiftool", ["-overwrite_original", "-gps:all=", path], parallelism: true) do
|
||||||
{_response, 0} -> :ok
|
{_response, 0} -> :ok
|
||||||
{error, 1} -> {:error, error}
|
{error, 1} -> {:error, error}
|
||||||
end
|
end
|
||||||
|
@ -21,6 +32,4 @@ def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
||||||
{:error, "exiftool command not found"}
|
{:error, "exiftool command not found"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter(_), do: :ok
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue