Exiftool: Strip all non-essential metadata tags #745

Merged
floatingghost merged 5 commits from Oneric/akkoma:exiftool-strip-all into develop 2024-04-26 17:38:47 +00:00
4 changed files with 16 additions and 6 deletions
Showing only changes of commit a95af3ee4c - Show all commits

View file

@ -37,7 +37,7 @@ If any of the options are left unspecified, you will be prompted interactively.
- `--static-dir <path>` - the directory custom public files should be read from (custom emojis, frontend bundle overrides, robots.txt, etc.)
- `--listen-ip <ip>` - the ip the app should listen to, defaults to 127.0.0.1
- `--listen-port <port>` - the port the app should listen to, defaults to 4000
- `--strip-uploads-metadata <Y|N>` - use ExifTool to strip uploads of sensitive metadata
- `--strip-uploads-metadata <Y|N>` - use ExifTool to strip uploads of metadata when possible
- `--read-uploads-description <Y|N>` - use ExifTool to read image descriptions from uploads
- `--anonymize-uploads <Y|N>` - randomize uploaded filenames
- `--dedupe-uploads <Y|N>` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames

View file

@ -656,7 +656,7 @@ This filter replaces the declared filename (not the path) of an upload.
#### Pleroma.Upload.Filter.Exiftool.StripMetadata
This filter only strips the GPS and location metadata with Exiftool leaving color profiles and attributes intact.
This filter strips metadata with Exiftool leaving color profiles and orientation intact.
No specific configuration.

View file

@ -172,10 +172,10 @@ defmodule Mix.Tasks.Pleroma.Instance do
{strip_uploads_metadata_message, strip_uploads_metadata_default} =
if Pleroma.Utils.command_available?("exiftool") do
{"Do you want to strip location (GPS) data from uploaded images? This requires exiftool, it was detected as installed. (y/n)",
{"Do you want to strip metadata from uploaded images? This requires exiftool, it was detected as installed. (y/n)",
"y"}
else
{"Do you want to strip location (GPS) data from uploaded images? This requires exiftool, it was detected as not installed, please install it if you answer yes. (y/n)",
{"Do you want to strip metadata from uploaded images? This requires exiftool, it was detected as not installed, please install it if you answer yes. (y/n)",
"n"}
end

View file

@ -4,7 +4,7 @@
defmodule Pleroma.Upload.Filter.Exiftool.StripMetadata do
@moduledoc """
Strips GPS related EXIF tags and overwrites the file in place.
Tries to strip all image metadata but colorspace and orientation overwriting the file in place.
Also strips or replaces filesystem metadata e.g., timestamps.
"""
@behaviour Pleroma.Upload.Filter
@ -19,7 +19,17 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripMetadata do
try do
case System.cmd(
"exiftool",
["-ignoreMinorErrors", "-overwrite_original", "-gps:all=", file],
[
"-ignoreMinorErrors",
"-overwrite_original",
"-all=",
"-CommonIFD0=",
"-TagsFromFile",
"@",
"-ColorSpaceTags",
"-Orientation",
file
],
parallelism: true
) do
{_response, 0} -> {:ok, :filtered}