【发布时间】:2019-01-24 18:48:36
【问题描述】:
我有一个函数可以打开图像,调整它的大小,然后设置要包含在其调色板中的最大颜色数。然后将此修改后的图像用于内部处理。我的偏好是避免将图像保存到磁盘,然后立即打开。
有没有办法使用 MiniMagick::Tool::Convert 并将输出捕获到内存中?
def create_image_for_processing(image_path, resize, colors)
MiniMagick::Tool::Convert.new do |convert|
convert << image_path
convert << '-resize' << resize
convert << '-colors' << colors
convert << 'temp.png'
end
MiniMagick::Image.open('temp.png')
end
【问题讨论】:
标签: ruby minimagick