Handling LARGE image

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
snake211

Handling LARGE image

Post by snake211 »

Hi,

I want to append 8 .jpg images of size 2400x12000 (approximately 4mb each). Then, using the combined image, I want to crop them into smaller pieces. However, appending them seems to take forever. I used a very simple command "convert img1.jpg img2.jpg img3.jpg ... img8.jpg +append combined.jpg".

Here's my system info:
CPU: AMD Athlon 64 3800+ 512KB
Mem: 3GB

Can anyone help? Is it because of some kind of memory limit in ImageMagick? If so, is there any other image processing tool for the appending/cropping jobs??

Thank you in advance.

J.R.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Handling LARGE image

Post by snibgo »

Define "forever".

Is it using disk during processing?

Each image is 29 M pixels. Q16 needs 6 bytes per pixel, so 174 MB each file, or 1.392 GB for 8 files. So it may be caching pixels to disk. If so, Q8 may be better for you.

Have you thought about cropping each one, and appending those pieces together?
snibgo's IM pages: im.snibgo.com
snake211

Re: Handling LARGE image

Post by snake211 »

>>Define "forever"
I just got the result. It took 2324 secs for the append, and 44 secs for cropping one 256x256 subset out of the combined (19200x12000) image.

>>Each image is 29 M pixels. Q16 needs 6 bytes per pixel, so 174 MB each file, or 1.392 GB for 8 files. So it may be caching pixels to disk. If so, Q8 may be better for you.
Sorry, I do not understand this part. Does it mean that I need to install a different version of the ImageMagick?

>>Have you thought about cropping each one, and appending those pieces together?
Yes. In fact, that's what I have done first. However, it took quite longer than I expected (more than 6000 secs to get the tiles I want from 8 2400x12000 images). I have thousands of such image sets to crop. :(


BTW, I am using it on linux (Fedora).
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Handling LARGE image

Post by snibgo »

2324 seconds? Yikes. I suggest you find out the load on your CPU, memory and disk. I suspect your memory fills up, so IM has to use the disk. (My calculation shows you may need 1.392 GB out of your 3GB for the total image.) See the architecture document: http://www.imagemagick.org/script/architecture.php

Try a similar append command with just 4 images. Does this take 1162 seconds, or very much less?

Type "convert -version". Look for "Q8" or "Q16". Q8 uses 8 bits per channel per pixel. Q16 uses 16 bits. If you currently use Q16, then installing the Q8 version and using that instead will halve the memory use, so if memory is the issue, this will help.

If you can put the 8 images on the web and tell us the URLs, and give the exact command you are using, someone might try this out.
snibgo's IM pages: im.snibgo.com
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Handling LARGE image

Post by snibgo »

Just for fun, I tried this:

Code: Select all

convert -size 2400x12000 xc:blue xlblue.jpg
convert -size 2400x12000 xc:red xlred.jpg
convert -size 2400x12000 xc:green xlgreen.jpg
convert -size 2400x12000 xc:cyan xlcyan.jpg
convert -size 2400x12000 xc:yellow xlyellow.jpg
convert -size 2400x12000 xc:magenta xlmagenta.jpg
convert -size 2400x12000 xc:black xlblack.jpg
convert -size 2400x12000 xc:white xlwhite.jpg

convert xlblue.jpg xlred.jpg xlgreen.jpg +append xl4.jpg

convert ^
  xlblue.jpg xlred.jpg xlgreen.jpg xlcyan.jpg ^
  xlyellow.jpg xlmagenta.jpg xlblack.jpg xlwhite.jpg ^
  +append xl8.jpg
On Q8:
append 4 files: 14 seconds
append 8 files: 343 seconds. 61% memory use. Heavy read/write to a magick file in %TEMP%.

On Q16:
append 4 files: 16 seconds
append 8 files: 941 seconds. 80% memory use. Heavy read/write to 4 magick files in %TEMP%.

My laptop (4 GB, Windows 7) is also running a massive CPU-intensive job (IM is applying special effects to movie frames), so the append on Q16 might be reasonable on a quiet machine.

But this test shows a big difference between Q8 and Q16, because Q16 consumes all my available memory.
snibgo's IM pages: im.snibgo.com
Post Reply