Page 1 of 1

Crop gigapixel image

Posted: 2013-03-07T01:27:01-07:00
by agni451
I have a 4 gigapixel image in png format (~20.5GB) that I would like to split into equal tiles (in this case, 1,936 1920x1080 tiles). I have 32GB of memory on my system but apparently this is not enough. I have tried the following command line

Code: Select all

imgmgk-convert -define registry:temporary-path="D:\temp" "D:\Proj\full.png" -crop 1920x1080 +repage +adjoin -limit area 12gb -limit memory 12gb -limit map 12gb -limit file 512 "D:\Proj\crop_HD_%04d.png"
but the memory usage slowly creeps up to 100% and I have to kill it. From the documentation, I thought

Code: Select all

 -limit area 12gb 
would guarantee a memory usage limit of 12gb, but neither that or the other -limit switches seem to do anything. I even set environment variables for them (I'm on Windows 7 x64, so I did My Computer --> right-click --> Properties --> Advanced system settings --> environment variables and created new ones for MAGICK_AREA_LIMIT and MAGICK_MEMORY_LIMIT) but it did not work. How do I ensure that I only use 12GB or less so my computer doesn't crash?

Re: Crop gigapixel image

Posted: 2013-03-07T04:15:37-07:00
by magick
The -limit options should be the first options of your command line. Move them and try your command again (e.g. convert -limit ... image.png ...).

Re: Crop gigapixel image

Posted: 2013-03-19T22:13:11-07:00
by agni451
magick wrote:The -limit options should be the first options of your command line. Move them and try your command again (e.g. convert -limit ... image.png ...).
I tried just having -limit area 12gb at the front of the commandline, and it doesn't work. I then tried simply using -limit map 2gb, and it does allow it to create the images. However, it only uses 32MB of memory (yes, MB) and a lot of hard drive swapping. I have multiple gigapixel images (up to 20.2GP), and at this rate (using an SSD drive for swap space, BTW), it takes 4 minutes to create 100 tiles. At that rate, it would take nearly 7 hours to break up the 20.2GP image. Why can't I force it to use a reasonable amount of memory to do as much fast work as possible, and write the rest to disk?

Also, montage takes the same amount of time to do the opposite action.

Re: Crop gigapixel image

Posted: 2013-03-20T03:30:08-07:00
by magick

Re: Crop gigapixel image

Posted: 2013-03-20T19:12:56-07:00
by agni451
I seem to have gotten it under control. Two things that might go into the user manual- when using environment variables, I couldn't use SI units (ie, I had to set limits in bytes, not in MB or GB, etc). From browsing the forum, it seems as though this issue was patched 6 years ago, but for some reason it isn't working on Windows 7 x64. Also, the -limit area option controls private bytes, not working set which for these large images can be twice the private bytes. For example, I could have set the -limit area (or MAGICK_AREA_LIMIT) to 20GB, but it would still have caused a crash with my 32GB of memory because the working set might get as high as 40GB. Thanks for the help.