# webp is not compatible with exiftool at this time
def filter(%Pleroma.Upload{content_type: "image/webp"}), do: {:ok, :noop}
- def filter(%Pleroma.Upload{name: file, tempfile: path, content_type: "image" <> _}) do
- if Regex.match?(~r/\.(webp)$/i, file) do
- {:ok, :noop}
- else
- strip_exif(path)
- end
- end
-
- def filter(_), do: {:ok, :noop}
-
- defp strip_exif(path) do
+ def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
try do
- case System.cmd("exiftool", ["-overwrite_original", "-gps:all=", path], parallelism: true) do
+ case System.cmd("exiftool", ["-overwrite_original", "-gps:all=", file], parallelism: true) do
{_response, 0} -> {:ok, :filtered}
{error, 1} -> {:error, error}
end
{:error, "exiftool command not found"}
end
end
+
+ def filter(_), do: {:ok, :noop}
end
content_type: "image/webp"
}
- bad_type = %Pleroma.Upload{
- name: "sample.webp",
- content_type: "image/jpeg"
- }
-
assert Filter.Exiftool.filter(upload) == {:ok, :noop}
- assert Filter.Exiftool.filter(bad_type) == {:ok, :noop}
end
end