filter exif data #187
authorTristan Mahé <gled@remote-shell.net>
Tue, 26 Jun 2018 20:45:47 +0000 (13:45 -0700)
committerTristan Mahé <gled@remote-shell.net>
Tue, 26 Jun 2018 20:45:47 +0000 (13:45 -0700)
config/config.exs
lib/pleroma/upload.ex
mix.exs

index cf6cbaa9d140697be8017cdd63b4e1a77bb08250..fd9662aeacac4a68fa9670315adef9ff6c6051b0 100644 (file)
@@ -10,7 +10,9 @@ config :pleroma, ecto_repos: [Pleroma.Repo]
 
 config :pleroma, Pleroma.Repo, types: Pleroma.PostgresTypes
 
-config :pleroma, Pleroma.Upload, uploads: "uploads"
+config :pleroma, Pleroma.Upload, 
+  uploads: "uploads",
+  strip_exif: false
 
 # Configures the endpoint
 config :pleroma, Pleroma.Web.Endpoint,
index 43df0d418f193ff8e1dcb9a1856915dc8879ea20..dee281f5b8ae7fd9f4c542cc50f390a626c1c564 100644 (file)
@@ -80,6 +80,14 @@ defmodule Pleroma.Upload do
     }
   end
 
+  def strip_exif_data(file) do
+    settings = Application.get_env(:pleroma, Pleroma.Upload)
+    @do_strip = Keyword.fetch!(settings, :strip_exif)
+    if @do_strip == true do
+       Mogrify.open(file) |> Mogrify.custom("strip") |> Mogrify.save(in_place: true)   
+    end
+  end
+
   def upload_path do
     settings = Application.get_env(:pleroma, Pleroma.Upload)
     Keyword.fetch!(settings, :uploads)
diff --git a/mix.exs b/mix.exs
index 28168729486989c62d36c00a079e5d969f091739..cc279a7f9daad550e22e365e75954769727bd166 100644 (file)
--- a/mix.exs
+++ b/mix.exs
@@ -47,7 +47,8 @@ defmodule Pleroma.Mixfile do
       {:jason, "~> 1.0"},
       {:ex_machina, "~> 2.0", only: :test},
       {:credo, "~> 0.7", only: [:dev, :test]},
-      {:mock, "~> 0.3.0", only: :test}
+      {:mock, "~> 0.3.0", only: :test},
+      {:mogrify, "~> 0.6.1"}
     ]
   end