]> cat aescling's git repositories - mastodon.git/commitdiff
Unconditionally re-encode locally-uploaded images to strip metadata (#8714)
authorThibG <thib@sitedethib.com>
Mon, 17 Sep 2018 18:24:46 +0000 (20:24 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Mon, 17 Sep 2018 18:24:46 +0000 (20:24 +0200)
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

index ea675a5bf4432531bc0c5fd3e0fdeda307677c8d..542c17fb20efdfab33f4f3402fa38927c39ac634 100644 (file)
@@ -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