Problem with image offset

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
Posts: 1
Joined: 2015-06-12T07:04:18-07:00
Authentication code: 6789

Problem with image offset

Post by k0sm4s » 2015-06-12T07:19:05-07:00

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;
                MagickImage frame = new MagickImage("korniza.png");

                using (MagickImage result = images.Mosaic())
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.

User avatar
Posts: 1576
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789

Re: Problem with image offset

Post by dlemstra » 2015-06-22T14:04:01-07:00

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);

  using (MagickImage moscaic = collection.Mosaic())
I will see if I can make this more clear in the API.
.NET + ImageMagick = Magick.NET, @MagickNET, Donate

Post Reply