From: Tim Hunter Date: 2009-04-30T10:41:44+09:00 Subject: Re: composite gif files with RMagick Wu Junchen wrote: > Tim Hunter wrote: > >> I'm assuming that you want to composite a 71x73 image 5 pixels from the >> top and 5 pixels from the left over a 128x128 image. Probably the page >> offset (+29+13) is screwing you up. >> > > Thanks,I have an image in a gif frame,which size is 71x73,and it has a > 128x128 page and 29+13 offset,I want to composite a 10X10 image 5 pixels > from the > top and 5 pixels from the left over the page,but not over the image in > the page,there is some way to do it? > gif1[i].composite(gif2[i],5,5,CompositeOperator::OverCompositeOp) will > add 5+39 and 5+13 offset over the page. When I composite a 10x10 image over a 71x73 image with a 128x128+29+13 page, I end up with a 71x73 image with a 128x128+29+13 image. That is, the resulting image has the same size and page attribute. If you want end up with a 128x128 image, you'll have to start with one and composite the smaller images over it. Something like this. You could of course make the "page" image transparent. Here I've made it black so you can see how the other two images are positioned. require 'RMagick' page = Magick::Image.new(128, 128) {self.background_color = "black" } back = Magick::Image.new(128, 128) {self.background_color = "cyan" } back.crop!(29, 13, 71, 73) page.composite!(back, Magick::CenterGravity, Magick::OverCompositeOp) front = Magick::Image.new(10, 10) {self.background_color = "red" } result = page.composite(front, 5, 5, Magick::OverCompositeOp) p result result.display -- RMagick: http://rmagick.rubyforge.org/