【发布时间】:2021-09-02 12:16:13
【问题描述】:
我正在使用 MiniMagick 调整图像大小。我的方法看起来像这样:
def resize
mini_img = MiniMagick::Image.new(img.tempfile.path)
mini_img.combine_options do |c|
c.resize '50x50^'
c.gravity 'center'
c.extent '50x50'
end
mini_img
end
调整大小有效,但问题是当我尝试将 mini_img 保存到 Active Storage 时,因为我收到错误 Could not find or build blob: expected attachable, got #<MiniMagick::Image。我可以以某种方式将 MiniMagick::Image (mini_img) 转换为普通图像并将其保存到 Active Storage 中吗?
【问题讨论】:
标签: ruby-on-rails ruby rails-activestorage minimagick