Fixing ‘cache resources exhausted’ errors in imview

1 minute read

imview is a handy image viewing application for Linux. I’ve started using this at $work recently, because Eye of Gnome, a.k.a eog, (my usual go-to application for image viewing) doesn’t handle histogram stretching of GeoTIFF images (TIFF images with embedded geographical metadata). It’s not that I expect eog to handle geo-encoded TIFFs – it does display them – it’s just that the images I need to view are too dark in eog (actually, they’re usually completely black) and so the image features can’t be seen. Thus the histogram of pixel values needs to be stretched to the full range of possible values so that the image details can seen. imview seems to directly load images with a normalised histogram and hence image features can be seen straight away. The application might be showing its age and hasn’t been updated in several years, however it’s main strength in my use case is that it’s fast.

I tend to work with large GeoTIFF images (several hundred megabytes to gigabytes in size), hence I stumbled upon a problem with the default settings delivered on Debian-based systems (I use “jessie” at the moment). When loading a sufficiently large file I kept getting the error Cache resources exhausted. This actually turned out to be an ImageMagick issue (since imview uses ImageMagick in the background); see for instance the Debian bug report about the issue. What the error is trying to say is that the amount of disk space allocated for caching of image data wasn’t large enough for the image being loaded. It turns out that this is the Disk resource limit within ImageMagick.

It’s possible to see the current resource limits by using the identify command from ImageMagick:

$ identify -list resource

By default, the disk resource limit is set to 1GiB. To change this value, one needs to edit /etc/ImageMagick-6/policy.xml and look for this line:

<policy domain="resource" name="disk" value="1GiB"/>

In my case bumping the value attribute to 5GiB solved the issue, and I can now happily view multi-gigabyte GeoTIFF images of polar ice without any problems:

Arctic ice in imview

Hope this tip was able to help someone!

Support

If you liked this post and want to see more like this, please buy me a coffee!

buy me a coffee logo