Page 1 of 1
How do I limit disk usage?
Posted: 2010-03-30T10:37:05-07:00
by chris
Hello,
I am experiencing a problem where processing a file with a very large available pallet (approx. 200" x 200") is consuming all of the available memory on my web server.
We use version 6.4.6-Q16 installed on a Windows server. I changed the following keys in the config.xml file in the
\config directory:
<configure name="MAGICK_MEMORY_LIMIT" value="32000000"/>
<configure name="MAGICK_MAP_LIMIT" value="64000000"/>
<configure name="MAGICK_AREA_LIMIT" value="64000000"/>
<configure name="MAGICK_DISK_LIMIT" value="500000"/>
<configure name="MAGICK_FILE_LIMIT" value="20"/>
This, however, did NOT limit the file's disk consumption. The temporary file grew to 810MB. I DO want the file to fail and throw an error since it isn't usable to us.
Please help. How do I limit the disk usage? What I've done so far doesn't seem to be working.
Re: How do I limit disk usage?
Posted: 2010-03-30T11:05:21-07:00
by magick
Type
Does it report values that match your limits (e.g. a File limit of 20)?
You could always set environment variables, e.g. MAGICK_MEMORY_LIMIT.
Have you read
http://www.imagemagick.org/script/resources.php and
http://www.imagemagick.org/script/architecture.php? If you set a low disk limit, ImageMagick exits if the limit is reached.
Re: How do I limit disk usage?
Posted: 2010-03-30T11:57:21-07:00
by chris
Yes, the setting match my inputs. Disk is set to 488kb. HOWEVER, I'm seeing a file in the temp directory that is 810,005 KB. The Disk setting apparently has no effect. What am I doing wrong?
Re: How do I limit disk usage?
Posted: 2010-03-30T12:03:40-07:00
by magick
The disk limit is in megabytes. Try reducing its value.
Re: How do I limit disk usage?
Posted: 2010-03-30T12:16:56-07:00
by chris
I set it to a value of 1 in configure.xml, which should be 1MB. Still no luck. The file size made it up to 810,005KB.
Re: How do I limit disk usage?
Posted: 2010-03-30T12:46:33-07:00
by chris
Further, I added those keys to the System Environment Variables and still, nothing changed.
Re: How do I limit disk usage?
Posted: 2010-03-30T14:24:49-07:00
by magick
Which file size? Disk limits only apply to the pixel cache, not the final output image. Add -debug cache to your command line to track the size of the pixel cache on disk.
Re: How do I limit disk usage?
Posted: 2010-03-31T04:49:09-07:00
by chris
The temp file size in c:\windows\temp. There are actually about 5 separate magick-*.tmp files created. 4 of the 5 are small, but there is always the one file that grows to 810MB. I'm using image magick to programmatically resize the image file and create a thumbnail. Here is the C#code:
Code: Select all
public const int MAX_THUMBNAIL_WIDTH = 256;
public const int MAX_THUMBNAIL_HEIGHT = 256;
public const String THUMBNAIL_FORMAT = ".jpg";
// Load into ImageMagick image
Stream byteStream = new MemoryStream(asset.AssetData); //asset.AssetData is a byte array representing the file
try
{
MagickNet.Image image = new Image(byteStream);
// If the current image is small, don't enlarge it.
int newWidth = Math.Min(image.Size.Width, MAX_THUMBNAIL_WIDTH);
int newHeight = Math.Min(image.Size.Height, MAX_THUMBNAIL_HEIGHT);
Blob thumbnail = new Blob();
if (fileExtension.Equals("psd"))
{
// Photoshop file must be converted before it's resized
image.Write(thumbnail, "JPG");
image = new Image(thumbnail);
}
// Resize to thumbnail, then save to thumbnail format
image.Resize(new Geometry(newWidth, newHeight));
image.Density = new MagickNet.Image.Resolution(72.0, 72.0);
image.Write(thumbnail, "JPG");
// Save blob back into Asset object
asset.PreviewThumbnail = thumbnail.ToArray();
}
The image that is causing a problem is an eps file that is approximately 200" high and 200" wide. Do I need to convert from .eps to a .jpg before resizing to a thumbnail?
Re: How do I limit disk usage?
Posted: 2010-03-31T05:25:31-07:00
by magick
EPS are first preprocessed by Ghostscript. ImageMagick limits only apply to the pixel cache, not intermediate files created by delegate libraries or utilities. You can write a preprocessor program that reads the dimensions from an EPS program and reject it if its too large-- before you call the ImageMagick API.