Page 1 of 1

Problem with image offset

Posted: 2015-06-12T07:19:05-07:00
by k0sm4s
Hello everybody,

I'm new in using imagemagick and I have a problem.
I'm trying to combine to images in one and everything works fine except the offset of my first image. I m tring to put a small image in the center of a second which is a frame but it doesnt move in anyway and keeps appearing in the top-left corner. Here's my code

Code: Select all

 using (MagickImageCollection images = new MagickImageCollection())
            {

                MagickImage first = new MagickImage(name);              
                first.Format = MagickFormat.Png;                   
                MagickGeometry size = new MagickGeometry(210,180,640, 442);
                size.IgnoreAspectRatio = true;
                first.AdaptiveResize(size);
                images.Add(first);
           
                MagickImage frame = new MagickImage("korniza.png");
                images.Add(frame);


                using (MagickImage result = images.Mosaic())
                {
                    result.Write("Mosaic.png");
                }
            }
I've also tried the size.X command and the first.Page.X but still nothing.

My guess is tha the image must be relative to something if it is to get an offset but I don't know hot to do that either.

Please give me a hand in this,
thank you in advance.

Re: Problem with image offset

Posted: 2015-06-22T14:04:01-07:00
by dlemstra
You might already solved this but it was probably not working because you did not realize that IamgeMagick.Page would return a new instance instead of the same object. You should write the code like this:

Code: Select all

using (MagickImageCollection collection = new MagickImageCollection())
{
  collection.Add(new MagickImage(new MagickColor("purple"), 1024,1024));
  MagickImage frame = new MagickImage("logo:");
  frame.Page = new MagickGeometry(300, 100, 0, 0);
  collection.Add(frame);

  using (MagickImage moscaic = collection.Mosaic())
  {
    moscaic.Write(@"C:\Mosaic.png");
  }
}
I will see if I can make this more clear in the API.