今天我尝试编写一个从文件夹生成动画 gif 的代码,但我收到了这个错误:
.../.gem/ruby/2.0.0/gems/rmagick-2.13.2/lib/RMagick.rb:1635:in `read': unable to open image `0.jpg,3.jpg,1.jpg,2.jpg': No such file or directory @ error/blob.c/OpenBlob/2641 (Magick::ImageMagickError)
from .../.gem/ruby/2.0.0/gems/rmagick-2.13.2/lib/RMagick.rb:1635:in `block in initialize'
.../.gem/ruby/2.0.0/gems/rmagick-2.13.2/lib/RMagick.rb:1634:in `each'
.../.gem/ruby/2.0.0/gems/rmagick-2.13.2/lib/RMagick.rb:1634:in `initialize'
from .../bin/scripts/animate.rb:20:in `new'
from .../bin/scripts/animate.rb:20:in `<main>'
这是代码:
#!/usr/bin/env ruby
require 'RMagick'
include Magick
files = Dir.glob"*.jpg"
if (!ARGV[0])
puts "Usage:"
puts "animate.rb 10"
puts "-0 delay ex. 10"
else
f = files.join(',').to_s
animation = ImageList.new("#{f}")
animation.delay = ARGV[0].to_i
animation.write("animated.gif")
exit
end
非常感谢 ;)