aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/upload.ex14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex
index 92a89e296..408a3fc56 100644
--- a/lib/pleroma/upload.ex
+++ b/lib/pleroma/upload.ex
@@ -18,6 +18,8 @@ defmodule Pleroma.Upload do
File.cp!(file.path, result_file)
end
+ strip_exif_data(content_type, result_file)
+
%{
"type" => "Document",
"url" => [
@@ -67,6 +69,8 @@ defmodule Pleroma.Upload do
File.rename(uuidpath, result_file)
end
+ strip_exif_data(content_type, result_file)
+
%{
"type" => "Image",
"url" => [
@@ -80,6 +84,16 @@ defmodule Pleroma.Upload do
}
end
+ def strip_exif_data(content_type, file) do
+ settings = Application.get_env(:pleroma, Pleroma.Upload)
+ do_strip = Keyword.fetch!(settings, :strip_exif)
+ [filetype, ext] = String.split(content_type, "/")
+
+ if filetype == "image" and 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)