Posted on 2008-02-01 10:47
东方求败 阅读(161)
评论(0) 编辑 收藏 所属分类:
IT新闻
MojoMagick 的文档中 号称 更快,更简单并且没有内存泄露。但是目前还很简单
文档描述如下:
引用
cience releases MojoMagick, an Ruby language image library “that does very little” ™. There are several useful image tools that “do a lot” - MojoMagick is designed to just a few things:
* Be fast
* Don’t leak memory
* Make simple ImageMagick tasks, simple as Ruby tasks
* Permit direct access to ImageMagick for complex tasks (i.e. get out of your way)
* Provide a central access to ImageMagick for good code architecture
* Easy to extend
* Limit memory accessible to ImageMagick (where desired)
That’s what it does. It’s packaged as a Rails plugin, but does not require Rails to run. If there’s any interest, I’ll make it a gem (just ask).
安装
ruby script/plugin install svn://svn.misuse.org/science/mojo_magick/trunk
使用
#获取图片的尺寸 (假设图片为 "120wx222h")
dimensions = MojoMagick::get_image_size(test_image)
# ==> dimensions now holds a hash: {:height => 120, :width => 222}
# 调整图片大小
MojoMagick::resize('/img/test.jpg', '/img/test2.jpg', {:width=>100, :height=>200})
呵呵,没了,这个东西才0.0.1,也许下一个版本会有更多的功能出现。