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
|
||||
- Migrations not working on OTP releases if the database was connected over ssl
|
||||
- Fix relay following
|
||||
- Fixed uploading webp images when the Exiftool Upload Filter is enabled
|
||||
|
||||
## [2.0.7] - 2020-06-13
|
||||
|
||||
|
@ -10,9 +10,20 @@ defmodule Pleroma.Upload.Filter.Exiftool do
|
||||
@behaviour Pleroma.Upload.Filter
|
||||
|
||||
@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
|
||||
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
|
||||
{error, 1} -> {:error, error}
|
||||
end
|
||||
@ -21,6 +32,4 @@ defmodule Pleroma.Upload.Filter.Exiftool do
|
||||
{:error, "exiftool command not found"}
|
||||
end
|
||||
end
|
||||
|
||||
def filter(_), do: :ok
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user