about summary refs log tree commit diff
path: root/app/models/preview_card.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-02-23 15:05:00 -0600
committerGitHub <noreply@github.com>2018-02-23 15:05:00 -0600
commitf53953d28a24fe65f1ca66d85a1416ba30dcda86 (patch)
tree4e9e2214629b46ddc98fdce358abc812112f13fa /app/models/preview_card.rb
parent544543e40a723d9719f5571bd4c3455a6a69fccd (diff)
parentf2f19e1f8a3a048cf0a0041ae54d912acfea7742 (diff)
Merge pull request #369 from KnzkDev/merge-upstream
Merge with upstream @ e668180044560e28bdc5eef94744c210013efcda
Diffstat (limited to 'app/models/preview_card.rb')
-rw-r--r--app/models/preview_card.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb
index 716b82243..86eecdfe5 100644
--- a/app/models/preview_card.rb
+++ b/app/models/preview_card.rb
@@ -33,7 +33,7 @@ class PreviewCard < ApplicationRecord
 
   has_and_belongs_to_many :statuses
 
-  has_attached_file :image, styles: { original: '400x400>' }, convert_options: { all: '-quality 80 -strip' }
+  has_attached_file :image, styles: { original: { geometry: '400x400>', file_geometry_parser: FastGeometryParser } }, convert_options: { all: '-quality 80 -strip' }
 
   include Attachmentable
   include Remotable
@@ -58,10 +58,11 @@ class PreviewCard < ApplicationRecord
 
     return if file.nil?
 
-    geo         = Paperclip::Geometry.from_file(file)
-    self.width  = geo.width.to_i
-    self.height = geo.height.to_i
-  rescue Paperclip::Errors::NotIdentifiedByImageMagickError
-    nil
+    width, height = FastImage.size(file.path)
+
+    return nil if width.nil?
+
+    self.width  = width
+    self.height = height
   end
 end