I need to morph two given images of different size:

smallimage.jpg (640x480 pixels at 72dpi) (no alpha channel)
bigimage.jpg (1024x768pixels at 72dpi) (no alpha channel)

I need to start the morph with smallimage.jpg
on top and at the center of bigimage.jpg
the morph has to happen in 8 frames, at the end, in frame 8,
bigimage.jpg will be seen and smallimage.jpg will have disappeared.

I'm near from getting the correct effect, but still not quite there yet,
I get a black border on the four sides of the smallimage.jpg
instead of a transparent border; so that the background image that is
the bigimage.jpg can't be seen correctly.

This I do not want, I want smallimage.jpg to mantain it's smaller size
on center of bigimage.jpg and it's four border sides to be transparent, and have it
morph and disappear in 8 frames, so it looks something like this:

Frame 1
--------------------------------------------------
|                   bigimage.jpg                   |
|                                                             |
|                                                             |
|               --------------------------             |
|               |  smallimage.jpg  |             |
|               |                               |             |
|               |   covers this         |             |
|               |   part of                 |             |
|               |   bigimage.jpg     |             |
|               --------------------------             |
|                                                             |
|                                                             |
|                                                             |
--------------------------------------------------
                          .
                          .
                          .
                          .
Frame 8
--------------------------------------------------
|                   bigimage.jpg                   |
|                                                             |
|                                                             |
|                                                             |
|                                                             |
|                                                             |
|                 smallimage.jpg                 |
|                          has                             |
|                    disappeared                   |
|                                                             |
|                                                             |
|                                                             |
|                                                             |
--------------------------------------------------

This is the code I have, I would appreciate help:

#! /usr/local/bin/ruby -w

  require 'RMagick'
  include Magick

  begin
      img1 = Image.read("smallimage.jpg").first
    rescue Magick::ImageMagickError
      puts "ERROR: " + $! + "\n"
      puts "#{$0}: ImageMagickError - #{$!}"
  end

  begin
      img2 = Image.read("bigimage.jpg").first
    rescue Magick::ImageMagickError
      puts "ERROR: " + $! + "\n"
      puts "#{$0}: ImageMagickError - #{$!}"
  end

bigmask = Magick::Image.new(img2.columns, img2.rows) { self.background_color = "black" }
  bigmask.matte = false

  smallmask = Magick::Image.new(img1.columns, img1.rows)
  smallmask.matte = false

maskok = Magick::Image.new(img2.columns, img2.rows) { self.background_color = "black" }
  maskok.matte = true
  maskok = bigmask.composite(smallmask, CenterGravity, OverCompositeOp)


  imagewmask = Magick::Image.new(img2.columns, img2.rows)
  imagewmask.matte = true

imagewmask = imagewmask.composite(img1, CenterGravity, OverCompositeOp) imagewmask = imagewmask.composite(maskok, CenterGravity, CopyOpacityCompositeOp)

  img1 = imagewmask

  images = Magick::ImageList.new

  images.push(img1)
  images.push(img2)

  morph = images.morph 8
  morph.delay = 12
  morph.iterations = 3600

  morph.write "morphedimage.gif"
  GC.start

  exit

--------------------------




_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to