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

Merge huge images into one.

Feb 11, 2015 at 9:06 AM
Hello, I'm new in using Magick.NET.
And I need merge several huge images(each 29000x14500). I tried next sample:
static void Main(string[] args)
                 using (MagickImageCollection images = new MagickImageCollection())
                    // Add the first image
                    MagickImage first = new MagickImage(@"C:\Images\item1.jpg");

                    // Add the second image
                    MagickImage second = new MagickImage(@"C:\Images\item2.jpg");

                    // Add the second image
                    MagickImage third = new MagickImage(@"C:\Images\item3.jpg");
                    // Create a mosaic from both images
                    using (MagickImage result = images.Mosaic())
                        // Save the result
            catch (Exception ex)
And have next error:
HugeImageMerger.vshost.exe: Insufficient memory (case 4) `E:\itemresult.jpg' @ error/jpeg.c/JPEGErrorHandler/336

What wrong did I do?
Thanks in advance!
Feb 11, 2015 at 9:29 AM
JPEG/JFIF supports a maximum image size of 65535×65535 pixels ( Your width or height (not sure what mosaic does) is 29000x3 = 87000. You should pick a different output format if you want to create an image that big.
Feb 16, 2015 at 12:13 PM
Thanks. You are right.

One more question. There is need much space for merging so huge files. How can I change drive for caching/tempfiles?
Feb 16, 2015 at 12:45 PM
Edited Feb 16, 2015 at 12:45 PM
You can set the temp folder with MagickNET.SetTempDirectory.
Feb 16, 2015 at 1:00 PM
Thanks for help. And so fast response.

P.S. I took Mosaic method from sapmle(merge images) in Documentation branch ;)