kamama
2009-03-20 02:50
浏览 254
已采纳

rails中用mini_magick的256错误问题

model中我定义了一个测试的方法test_mini。用来处理参数pic_path传递过来的图片。

def test_mini(pic_path)
pic=MiniMagick::Image.new(pic_path)
#pic.border(200)
pic.font 'helvetica'
pic.draw 'text 100,100 "gogogogogogo"'
#pic.draw "image SrcOver 0,0 0,0 123.jpg"
end

出现了问题,如果我把最后pic.draw "image SrcOver 0,0 0,0 123.jpg"这句注释掉,那么这段代码是可以执行的,能够在上面写字。
但是我不注释掉这句在上面加水印的句子,就会出现错误。请问有没有人能帮到我?

错误信息
ImageMagick command (mogrify -draw "image SrcOver 0,0 0,0 123.jpg" "C:/Documents and Settings/jc/ruby/test/public/upload/17.jpg") failed: Error Given 256

c:/ruby/lib/ruby/gems/1.8/gems/mini_magick-1.2.3/lib/mini_magick.rb:124:in run_command'
c:/ruby/lib/ruby/gems/1.8/gems/mini_magick-1.2.3/lib/mini_magick.rb:93:in
method_missing'
app/models/product.rb:19:in test_mini'
app/controllers/products_controller.rb:68:in
update'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:106:in call'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:106:in
respond_to'
app/controllers/products_controller.rb:66:in update'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in perform_action_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in
call_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in perform_action_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
perform_action_without_rescue'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in measure'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
perform_action_without_rescue'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in perform_action_without_caching'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in
perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in cache'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in
cache'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in
send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in process_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in
process_without_session_management_support'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:392:in
process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:183:in handle_request'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:in
dispatch_unlocked'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:123:in dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in
synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:132:in
dispatch_cgi'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:39:in dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:103:in
handle_dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:74:in service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in
service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in run'
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in
start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in
start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in
each'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in
start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in start'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:60:in
dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/servers/webrick.rb:66
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in
new_constants_in'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in require'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
[b]问题补充:[/b]
我又测试了一下,除了draw,还有一些命令是同样出现这个问题的.
所以我也很奇怪.
如果是插件的问题,但是有些命令是可以实现的.
而同样的格式有人测试是可行的.也应该不是引用语法的错误.
那么问题出在哪呢?我google了一下,有人说是获取文件路径的问题.我觉得这个嫌疑也最大,但是我按照他的做法,加入了app的路径之后还是不行.很无奈
不知道大家有没有其他的一些配置要注意的地方我可能忽略了的?或者经验能分享一下呢?
[b]问题补充:[/b]
我的本地有123.jpg.......

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

4条回答 默认 最新

  • horace_lee 2009-03-23 07:54
    最佳回答

    你改一下你本地的123.jpg的文件,换成 不是数字开头的
    然后,draw的命令也换

    因为,单纯找不到文件,应该提示No such file or directory.

    不是mogrify: Non-conforming drawing primitive definition `image'

    评论
    解决 无用
    打赏 举报
查看更多回答(3条)

相关推荐 更多相似问题