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,也許下一個版本會有更多的功能出現。