Stitching together a large image with Magick++

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Acorn
Posts: 2
Joined: 2016-08-03T08:20:06-07:00
Authentication code: 1151

Stitching together a large image with Magick++

Post by Acorn »

Hello, everyone!

I am currently attempting to stitch together many images into one large image. Because of the 32-bit restrictions, I can not allocate enough memory to hold the entire image.
A coworker pointed me to the ImageMagick library, because "ImageMagick utilizes multiple computational threads to increase performance and can read, process, or write mega-, giga-, or tera-pixel image sizes."

My question is, is it possible to stitch together a couple hundred images that I can not do manually because of the 32-bit limit?
I've looked through the API, and I could not come to a clear answer.
It looks like I would have to generate my background image, and then use the composite function to stitch all of the images onto it.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Stitching together a large image with Magick++

Post by snibgo »

What "32-bit restrictions"? If your computer has a 2^32 limit on filesizes, IM won't overcome that.

IM can create and process images that are too large to fit in memory. However, there is a big performance penalty because disk is much slower than memory.
snibgo's IM pages: im.snibgo.com
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Stitching together a large image with Magick++

Post by GeeMack »

Acorn wrote:It looks like I would have to generate my background image, and then use the composite function to stitch all of the images onto it.
Compositing onto a background is one way to approach that, but there are other, often more effective ways to attach images to each other with ImageMagick, aligned side by side horizontally or vertically, with specific overlaps or offsets or spacing, just about any way you can imagine.
Acorn
Posts: 2
Joined: 2016-08-03T08:20:06-07:00
Authentication code: 1151

Re: Stitching together a large image with Magick++

Post by Acorn »

snibgo wrote:What "32-bit restrictions"? If your computer has a 2^32 limit on filesizes, IM won't overcome that.

IM can create and process images that are too large to fit in memory. However, there is a big performance penalty because disk is much slower than memory.
Yes, that is what I was alluding to. I know that there will be a performance hit, but I don't really have a choice at this point. I can't do 64-bit, so I'm stuck with 32-bit. If they want these obscenely large images mosaicked together, then I'm going to have to operate off of disk.
Could you point me in the right direction w/r/t the C function I should look at?
GeeMack wrote:
Acorn wrote:It looks like I would have to generate my background image, and then use the composite function to stitch all of the images onto it.
Compositing onto a background is one way to approach that, but there are other, often more effective ways to attach images to each other with ImageMagick, aligned side by side horizontally or vertically, with specific overlaps or offsets or spacing, just about any way you can imagine.
Am I able to do this off of disk rather than in-memory?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Stitching together a large image with Magick++

Post by snibgo »

Could you point me in the right direction w/r/t the C function I should look at?
To do what? There are C functions that correspond to most command-line options. For example, "-append" at the command line uses image.c function AppendImages().

Sometimes, a C program gives far better performance than a complex script because it can save on filesystem reads and writes. But for simple appends or composites from a number of inputs, there is probably no benefit.
snibgo's IM pages: im.snibgo.com
Post Reply