2020-07-10 23:46:26 +02:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Upload.Filter.Exiftool do
|
2020-07-11 00:07:28 +02:00
|
|
|
@moduledoc """
|
|
|
|
Strips GPS related EXIF tags and overwrites the file in place.
|
|
|
|
Also strips or replaces filesystem metadata e.g., timestamps.
|
|
|
|
"""
|
2020-07-10 23:46:26 +02:00
|
|
|
@behaviour Pleroma.Upload.Filter
|
|
|
|
|
2020-07-11 14:48:45 +02:00
|
|
|
require Logger
|
|
|
|
|
2020-07-10 23:46:26 +02:00
|
|
|
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
2020-07-11 14:48:45 +02:00
|
|
|
if Pleroma.Utils.command_available?("exiftool") do
|
|
|
|
System.cmd("exiftool", ["-overwrite_original", "-gps:all=", file], parallelism: true)
|
|
|
|
else
|
|
|
|
Logger.warn("exiftool is not available, filter #{__MODULE__} skipped")
|
|
|
|
end
|
|
|
|
|
2020-07-10 23:46:26 +02:00
|
|
|
:ok
|
|
|
|
end
|
|
|
|
|
|
|
|
def filter(_), do: :ok
|
|
|
|
end
|