为信封图像添加宽度、高度和大小。
Add width, height, and size to paperclip images.
Paperclip Meta gets image dimensions after post_process_styles using paperclip's Geometry.from_file.
Paperclip Meta works with paperclip version 5.x and 6.x.
Version 2.x works with paperclip version 4.x.
Add paperclip-meta to Gemfile:
gem 'paperclip-meta'Create migration to add a *_meta column:
class AddAvatarMetaToUsers 100
user.avatar.height(:medium)
=> 200
user.avatar.image_size
=> '60x70'
user.avatar.aspect_ratio
=> 1.5You can pass the image style to these methods. If a style is not passed, the default style will be used.
https://github.com/thoughtbot/paperclip/wiki/Extracting-image-dimensions
Test:
bundle
bundle exec rake暂无开放 Issues,或尚未同步最近议题。