W
Wu Junchen
I have two gif files,and I want to composite them,there is my ruby code:
require 'rmagick'
include Magick
gif1=ImageList.new('one.gif')
gif2=ImageList.new('two.gif')
dest=ImageList.new
0.upto(gif1.size-1){|i|
dest <<
gif1.composite(gif2[i%gif2.size],5,5,CompositeOperator::OverCompositeOp)
}
dest.write('test.gif')
However,the size of the gif1 frames are not the same:
irb(main):092:0> gif1[0]
=> gif.gif=>0.gif GIF 128x128 128x128+0+0 PseudoClass 256c 8-bit 2kb
irb(main):093:0> gif1[1]
=> gif.gif=>1.gif GIF 71x73 128x128+29+13 PseudoClass 256c 8-bit 2kb
the xy-offset can just applied to the frame size,eg:71*73,so if I give
it -29 and -13,I still can't get 128x128+0+0,how can I add all my gif2's
frame to gif1 on 128x128+5+5?And how can I get the x-offset and y-offset
of the gif file,I can't find some method to get the info '29+13'.
Any help will be appreciated!
Attachments:
http://www.ruby-forum.com/attachment/3627/gifs.zip
require 'rmagick'
include Magick
gif1=ImageList.new('one.gif')
gif2=ImageList.new('two.gif')
dest=ImageList.new
0.upto(gif1.size-1){|i|
dest <<
gif1.composite(gif2[i%gif2.size],5,5,CompositeOperator::OverCompositeOp)
}
dest.write('test.gif')
However,the size of the gif1 frames are not the same:
irb(main):092:0> gif1[0]
=> gif.gif=>0.gif GIF 128x128 128x128+0+0 PseudoClass 256c 8-bit 2kb
irb(main):093:0> gif1[1]
=> gif.gif=>1.gif GIF 71x73 128x128+29+13 PseudoClass 256c 8-bit 2kb
the xy-offset can just applied to the frame size,eg:71*73,so if I give
it -29 and -13,I still can't get 128x128+0+0,how can I add all my gif2's
frame to gif1 on 128x128+5+5?And how can I get the x-offset and y-offset
of the gif file,I can't find some method to get the info '29+13'.
Any help will be appreciated!
Attachments:
http://www.ruby-forum.com/attachment/3627/gifs.zip