6a40e152f95e2bcdf770f3abe85dcf265d10278e
[akkoma] / lib / pleroma / upload / filter / exiftool.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Upload.Filter.Exiftool do
6 @moduledoc """
7 Strips GPS related EXIF tags and overwrites the file in place.
8 Also strips or replaces filesystem metadata e.g., timestamps.
9 """
10 @behaviour Pleroma.Upload.Filter
11
12 require Logger
13
14 def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
15 if Pleroma.Utils.command_available?("exiftool") do
16 System.cmd("exiftool", ["-overwrite_original", "-gps:all=", file], parallelism: true)
17 :ok
18 else
19 {:error, "exiftool command not found"}
20 end
21 end
22
23 def filter(_), do: :ok
24 end