更改图像文件名rmagick

时间:2014-09-21 07:50:36

标签: ruby-on-rails ruby imagemagick rmagick

Rmagick博士并不是最清楚的,我已经尝试了所有的东西,但它并不喜欢它?也许我误解了Magick :: Info是如何运作的?

http://www.imagemagick.org/RMagick/doc/info.html

def crop_photo(url, x, y, w, h)
 image =  Magick::ImageList.new
 urlimage = open(url)
 format = url.split('/')[-1].strip.split('?')[0].strip
 image.from_blob(urlimage.read)
 crop = image.crop(x,y,w,h)
 image = crop.to_blob
    image.filename = format #doesn't work
    self.filename = format  #doesn't work
end

非常感谢帮助

1 个答案:

答案 0 :(得分:1)

要保存Image或ImageList,请使用write方法:

image.write(new_filename)