检查Minimagick的高度会冻结控制台 [英] Checking Minimagick height freezes console

查看:80
本文介绍了检查Minimagick的高度会冻结控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Rails与MiniMagick配合使用,并具有通过file_fieldMiniMagick::Image.read(image.read)上传的obj:

I'm using Rails with MiniMagick and have this obj that I've uploaded through file_field and MiniMagick::Image.read(image.read):

=> #<MiniMagick::Image:0x007feb61ac7048
 @info=#<MiniMagick::Image::Info:0x007feb61ac6ff8 @info={}, @path="/var/folders/s5/0r70nfzn2cj74qmc90ry3kc80000gp/T/mini_magick20170608-62480-1kxoub0">,
 @path="/var/folders/s5/0r70nfzn2cj74qmc90ry3kc80000gp/T/mini_magick20170608-62480-1kxoub0",
 @tempfile=#<File:/var/folders/s5/0r70nfzn2cj74qmc90ry3kc80000gp/T/mini_magick20170608-62480-1kxoub0 (closed)>>

我想用image['height']查看对象的高度,但是每当完成此操作时,命令行就会冻结或得到No live threads left. Deadlock?.如果我只是让程序在没有调试器的情况下运行,我会得到

I want to look into the object's height with image['height'] but whenever I've done that my command line freezes or I get No live threads left. Deadlock?. If I just let the program run without the debugger I get

`identify -format %m %w %h %b /var/folders/s5/0r70nfzn2cj74qmc90ry3kc80000gp/T/mini_magick20170608-62480-v5agnm[0]` failed with error: identify: no decode delegate for this image format `' @ error/constitute.c/ReadImage/509.

我尝试添加

MiniMagick.configure do |config|
  config.validate_on_create = false
  config.validate_on_write = false
end

但这没有帮助.

推荐答案

我认为问题出在您的图像路径中,要进行故障排除,请将RMagick排除在等式之外,然后进行测试即可 该文件的内容为:

I think the problem is in your image path, For troubleshooting take RMagick out of the equation and just test find the file with:

myfile = "#{RAILS_ROOT}/public/images/world.jpg"
  File.open myfile, 'r' { |f| puts "Success!\n\nFile Contents:" + f.read
}

此外,尝试使用脚本/控制台"来玩这个游戏.以上行 可以在那里输入.无需进行操作即可更轻松地进行实验 使Web服务器崩溃.

Also, try using "script/console" to play with this. The above lines can be typed in there. It will make it easier to experiment without crashing the web server.

获取您的参考

这篇关于检查Minimagick的高度会冻结控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆