?

Log in

No account? Create an account

Image merging

« previous entry | next entry »
Sep. 19th, 2012 | 03:05 pm

Can anyone recommend any good tools for combining/joining/merging/concatenating image files?

I'd need a tool that can handle a fairly large number of fairly-large images (1920 PNGs of 2048x2048 pixels each). My first thought was to use ImageMagick, but that turned out be useless — it appears to be lacking the kind of proper memory management that is necessary when you're dealing with large amounts of data, not just more data than will fit in memory (or memory plus swap, for that matter) but also more data than a 32-bit process can allocate on a 32-bit OS to begin with.

The source files themselves are fairly small, less than 50 MB of data in total. I could easily convert these files to a different format that's more suitable for processing, too; it would be nice if the final resulting image would be in a fairly well-compressed format such as PNG, but it's not a requirement — actually compressing an 8 gigapixel image might take too long for it to be feasible, and PNG compression might also interfere with easy viewing of the result, so if I'd end up with an uncompressed bitmap, that'd be fine.

Speaking of which, I'd also like a recommendation for an image viewer: one that would allow swift zooming in/out of and panning across an image that size.

I'm sure there are people who regularly have to deal with this sort of problem, and as such I'm sure there are solutions for this. Any pointers?

(And yes, this is about xkcd.)

Link | Leave a comment | Share

Comments {6}

Winterheart

(no subject)

from: winterheart01
date: Sep. 19th, 2012 04:53 pm (UTC)
Link

did you try running a 64-bit process on a 64-bit OS and try ImageMagick there? :)

I can't say about making such a huge picture though, all I use it for is thumbnails and then merging some of those thumbs onto one picture. (ovelaps)

But maybe you could investigate other libraries such as gd?

Reply | Thread

Schneelocke

(no subject)

from: schnee
date: Sep. 19th, 2012 05:21 pm (UTC)
Link

did you try running a 64-bit process on a 64-bit OS and try ImageMagick there? :)

No — I'd still need a system with a LOT of RAM for the "load all images into memory at once and then create the final image in memory before saving it" approach to work; given the amount of data involved, I'd estimate it'd have to be at least 64 GB. I don't have access to any machine with such specs.

gd might be an option, as long as it comes with command-line utilities to access its functionality (I'm only familiar with it as a library, but I don't want to roll my own, as it were, since then *I* would have to do all the work of creating something that works for fairly large images). Alas, the website seems to be down at the moment, with a git mercurial repo hosted off-site available.

Reply | Parent | Thread

The Mystery of the Supranational Rabbit

(no subject)

from: porsupah
date: Sep. 19th, 2012 07:52 pm (UTC)
Link

My first thought for something huge would be Potatoshop - it's grown up with the concept of gigantic images needing to be manipulated.

My second thought would be to let someone else perform the merging, and download their composite. Seems pretty much bound to happen. ^_^

And then there's just leaving them as they are, and letting some simple HTML stitch them together on viewing a local HTML file, which keeps the decoding task simple when you want to view it.

Reply | Thread

Schneelocke

(no subject)

from: schnee
date: Sep. 19th, 2012 08:03 pm (UTC)
Link

And then there's just leaving them as they are, and letting some simple HTML stitch them together on viewing a local HTML file, which keeps the decoding task simple when you want to view it.

That's a good option in theory, but in practice browsers (at least Firefox) tend to keep images in memory as bitmaps for easier/quicker access — fair enough, but not workable when you're dealing with something on the order of 8 gigapixels. :) (Even disregarding the missing tiles, there's still 184 actual images of 4 megapixels each, which would require a significant amount of memory.)

This approach'd also make zooming and panning nigh impossible.

That said, it's certainly workable, and someone's even already done it.

My first thought for something huge would be Potatoshop - it's grown up with the concept of gigantic images needing to be manipulated.

PotatoShop (heh) would be a good option if I had it. :) But I don't, and I'm not the sort who believes in illicit copies, so I'd have to make do with GIMP, which, despite having gotten a lot better, isn't exactly comparable.

BTW, how scriptable is PotatoShop? I'd also like to avoid having to arrange and merge 1920 images by hand. ^^

My second thought would be to let someone else perform the merging, and download their composite. Seems pretty much bound to happen. ^_^

Indeed — but I sort of hoped I'd be able to be the first to do it, or one of the first. ;)

Still, this may just be the option I'll have to go with in the end.

Reply | Parent | Thread

(Deleted comment)

Schneelocke

(no subject)

from: schnee
date: Sep. 19th, 2012 08:11 pm (UTC)
Link

Yup, I am — or was, rather. :) I've tinkered a bit more and tried to merge downscaled versions of the individual tiles, but even that's proving to be a hassle with ImageMagick, with errors such as "[main] montage 5960 C:\cygwin\bin\montage.exe: *** fatal error in forked process - failed to create new win32 semaphore, error -2" (yeah, I know, Cygwin; there's my problem, most likely) and more.

Good to know others are working on it. :) That'll allow me to do what porsupah suggested above and simply wait for someone else to do the work so that all I'll have to do is reap what I didn't sow. ;)

EDIT: Looking at those folks' effort, it seems I actually underestimated the number of tiles, too; for some reason I only went up to 8n (north), whereas in reality, they do go higher than that. Mea culpa — I was lazy, so I trusted that HTML file (also linked in my reply to porsupah) that someone else posted for the extents of the whole thing, and didn't bother checking if it actually covered everything.

EDIT2: Yeah, I definitely should wait for smarter/less lazy folks to do this, I think. :P

Edited at 2012-09-19 08:32 pm (UTC)

Reply | Parent | Thread