问题
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)>>
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.
I've tried adding in
MiniMagick.configure do |config|
config.validate_on_create = false
config.validate_on_write = false
end
But it hasn't helped.
回答1:
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
}
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.
for your reference
来源:https://stackoverflow.com/questions/44442569/checking-minimagick-height-freezes-console