do the filtering

This commit is contained in:
Tristan Mahé 2018-06-26 14:03:23 -07:00
parent c67cf8e9af
commit d8d43f1173
1 changed files with 7 additions and 2 deletions

View File

@ -18,6 +18,8 @@ def store(%Plug.Upload{} = file, should_dedupe) do
File.cp!(file.path, result_file) File.cp!(file.path, result_file)
end end
strip_exif_data(content_type, file.path)
%{ %{
"type" => "Image", "type" => "Image",
"url" => [ "url" => [
@ -67,6 +69,8 @@ def store(%{"img" => "data:image/" <> image_data}, should_dedupe) do
File.rename(uuidpath, result_file) File.rename(uuidpath, result_file)
end end
strip_exif_data(content_type, uuidpath)
%{ %{
"type" => "Image", "type" => "Image",
"url" => [ "url" => [
@ -80,11 +84,12 @@ def store(%{"img" => "data:image/" <> image_data}, should_dedupe) do
} }
end end
def strip_exif_data(file) do def strip_exif_data(content_type, file) do
settings = Application.get_env(:pleroma, Pleroma.Upload) settings = Application.get_env(:pleroma, Pleroma.Upload)
@do_strip = Keyword.fetch!(settings, :strip_exif) @do_strip = Keyword.fetch!(settings, :strip_exif)
[filetype, ext] = String.split(content_type, "/")
if @do_strip == true do if filetype == "image" and @do_strip == true do
Mogrify.open(file) |> Mogrify.custom("strip") |> Mogrify.save(in_place: true) Mogrify.open(file) |> Mogrify.custom("strip") |> Mogrify.save(in_place: true)
end end
end end