ruby-on-rails – Paperclip | ImageMagick – 无法使用自定义高
发布时间:2020-12-17 01:56:47 所属栏目:百科 来源:网络整理
导读:我正在使用Paperclip的自定义样式来调整某些图像的大小. 自定义样式定义如此 – has_attached_file :image_preview,:styles = lambda { |a| { :original = "#{a.instance.model.aspect_ratio_width.to_f/2.54*300}x#{a.instance.model.aspect_ratio_height.t
我正在使用Paperclip的自定义样式来调整某些图像的大小.
自定义样式定义如此 – has_attached_file :image_preview,:styles => lambda { |a| { :original => "#{a.instance.model.aspect_ratio_width.to_f/2.54*300}x#{a.instance.model.aspect_ratio_height.to_f/2.54*300}"} } 当看到输出时,图像被调整为宽度参数但从不调整高度参数! 在日志中,我看到在ImageMagick操作期间只考虑了width参数 – Command :: file -b --mime '/tmp/46711c9258f556a83aa382084f5014d120160804-14501-h9qo6j.png' Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/46711c9258f556a83aa382084f5014d120160804-14501-16cbj3b.png[0]' 2>/dev/null Command :: identify -format %m '/tmp/46711c9258f556a83aa382084f5014d120160804-14501-16cbj3b.png[0]' Command :: convert '/tmp/46711c9258f556a83aa382084f5014d120160804-14501-16cbj3b.png[0]' -auto-orient -resize "1110" '/tmp/caba5ed9a9c1d9623acb7738fd6b8dda20160804-14501-5sjqq1' [paperclip] saving /cases/image_previews/000/000/045/original/Goku-Blue.png 我怎样才能做到这一点? 解决方法
您可以像这样定义高度和宽度:
has_attached_file:image_preview,:styles {original:“1920×1080>”,thumb:“300×300#”} ‘#’会将中心的图像切割为给定的尺寸. https://github.com/thoughtbot/paperclip#quick-start (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |