This project has moved. For the latest updates, please go here.

Magicknet web application throwing Unable to Extend Cache error

Jul 2, 2013 at 7:57 PM
Edited Jul 2, 2013 at 7:58 PM
I'm writing a web application which needs to scale images. My code is as follows:
MagickImage theImage = new MagickImage(Server.MapPath(relativePath));
theImage.Scale(350);
The Scale function call throws a MagickCacheErrorException: Magick: unable to extend cache
This article shows how to use a disk file to solve the problem. I cannot figure out how to get Magick.net to do that.
Thanks for any help
Jon
Coordinator
Jul 2, 2013 at 10:25 PM
Does your application pool have a memory limit? It seems that ImageMagick does not have enough memory and wants to use disk space for the pixel cache. I will try to reproduce the problem and see if I can fix it.
Jul 2, 2013 at 10:40 PM
Thanks for the reply - the application pool does not have a limit, but I think I may have found the problem. The Scale call seems to get grumpy with only the single integer parameter. Adding a second integer to the call fixes the problem.
 theImage.Scale(350, 200) 
The original call was based on the command line version of ImageMagick which allowed scaling to some width while keeping the image's aspect ratio in tact. How would I do that in the current case?
Coordinator
Jul 2, 2013 at 11:06 PM
When you use the method with one argument you are supplying a percentage. Because there is an implicit cast from double to percentage it will become 35000% and you will probably run into a memory limit :). When you want to preserve the same aspect ratio you should supply 0 for the height.
theImage.Scale(350, 0);
Jul 3, 2013 at 4:57 AM
Ah...Thank you very much.