about summary refs log tree commit diff
path: root/lib/paperclip
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2018-09-17 20:24:46 +0200
committerThibG <thib@sitedethib.com>2018-09-17 21:09:59 +0200
commit382cdd7f959480d59fee5646be320d6076cb18d8 (patch)
tree866bcad1cc985c0277d09e53027030f3c4a84fcc /lib/paperclip
parent657805f444ffd8d1cc0a36e0c37276a01611dc26 (diff)
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.
Diffstat (limited to 'lib/paperclip')
-rw-r--r--lib/paperclip/lazy_thumbnail.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/paperclip/lazy_thumbnail.rb b/lib/paperclip/lazy_thumbnail.rb
index ea675a5bf..542c17fb2 100644
--- a/lib/paperclip/lazy_thumbnail.rb
+++ b/lib/paperclip/lazy_thumbnail.rb
@@ -20,7 +20,7 @@ module Paperclip
     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 @@ module Paperclip
     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