rmagick有一种方法可以在内存中转换图像 [英] rmagick is there a way to convert image in memory
本文介绍了rmagick有一种方法可以在内存中转换图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从 Rmagick
指南:
将图像转换为其他格式
将图像转换为另一种格式就像将
图像写入文件一样简单。
Converting an image to another format is as simple as writing the image to a file.
ImageMagick使用输出文件名后缀(JPEG的.jpg
或
,GIF的.gif)前缀(ps:表示
来确定输出图像的格式。
PostScript,例如)
ImageMagick uses the output filename suffix (".jpg"
for JPEG, ".gif" for GIF, for example)
or prefix ("ps:" for
PostScript, for example)
to determine the format of the output image.
有没有办法在内存中转换图像?
Is there a way to convert image in memory?
推荐答案
# assuming you have an image
# img = Magick::Image.new( 100, 100 )
img = Magick::Image.from_blob( img.to_blob { self.format = "png" } )
来源: RMagick Docs
下面是关于如何给它给用户
image.format = "png"
send_data image.to_blob,
:filename => "woohoo.png",
:disposition => 'inline',
:quality => 90,
:type => 'image/png'
这篇关于rmagick有一种方法可以在内存中转换图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文