This project has moved. For the latest updates, please go here.

Clone an existing image to a new one

Dec 28, 2016 at 2:49 AM
Hello everyone.
I've searched a bit around the discussions\forums, but i couldn't find much information about how to achieve what i'm trying.
Also, i don't see much Magick.NET documentation - where i could obtain it :)

What i'm trying to do is:
I have an very large MagickImage object (9920 width , 7085 height). Its an tiff file i loaded and rotated.

I would like to create a new MagickImage object, larger (10594 width , 7387 height) and place the smaller MagickImage object in the middle of it. I'll be placing also into the upleft position, upright...but thats my next step. For now i just want to place it in the middle of the larger Magickimage , and add some borders. Also, i need this new MagickImage object(the larger one) to have transparent background.

What i tried , but couldn't get any further was:
MagickReadSettings Settings = new MagickReadSettings();
            Settings.Width = Convert.ToInt32(zoneAreaWidth_Pixels);
            Settings.Height = Convert.ToInt32(zoneAreaHeight_Pixels);
            using (MagickImage inkZoneImage = new MagickImage(loadedImage))
                //How to use settings here ?
                //How to position the loadedImage in the middle of inkZoneImage ?

And , this is my question. Any help will be greatly appreciated.
Thanks in advance.

Best Regards,
Pablo Costa.
Dec 28, 2016 at 9:30 PM
Edited Dec 29, 2016 at 5:56 AM
What you could do is extent the image:
MagickColor background = MagickColors.Fuchsia;
Gravity gravity = Gravity.Center;
loadedImage.Extent(zoneAreaWidth_Pixels, zoneAreaHeight_Pixels, gravity, background);
You can adjust background for the background color and gravity for the position.

A lot of documentation for ImageMagick can be found here: