From 5de558db396f0744de735347f81b20c1c0228901 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Mon, 17 Sep 2018 15:14:17 +0200 Subject: [PATCH] Unconditionally re-encode locally-uploaded images to strip metadata This strips metadata on file upload by re-encoding the files, at the cost of possible slight image quality decrease and processing resources. --- lib/paperclip/lazy_thumbnail.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/paperclip/lazy_thumbnail.rb b/lib/paperclip/lazy_thumbnail.rb index ea675a5bf4432..542c17fb20efd 100644 --- a/lib/paperclip/lazy_thumbnail.rb +++ b/lib/paperclip/lazy_thumbnail.rb @@ -20,7 +20,7 @@ def make private def needs_convert? - needs_different_geometry? || needs_different_format? + needs_different_geometry? || needs_different_format? || needs_metadata_stripping? end def needs_different_geometry? @@ -31,5 +31,9 @@ def needs_different_geometry? def needs_different_format? @format.present? && @current_format != @format end + + def needs_metadata_stripping? + @attachment.instance.respond_to?(:local?) && @attachment.instance.local? + end end end