Page 1 of 1

Running out of space...or not

Posted: 2013-07-10T06:27:52-07:00
by farbewerk
I'm running a script to create a 2px by 2px png file for each of the possible 16.7 million colors available in the hex color spectrum. Here's the script:

Code: Select all

#! /usr/bin/sh
list=$(cat newhexcodes.txt)
	for color in $list; do

	convert -size 2x2 xc:"#$color" $color.png

done
newhexcodes.txt contains a list of all possible hex colors. Please don't ask why I have to do this instead of auto generating the images at run time. Suffice it to say, I just do. I know that it's very kludgey.

Things begin nicely. I've created a virtual machine with CentOS 6.4 and allocated 1.5 gig of RAM to it. At some point, I get this error:

convert: unable to open image `268611.png': No space left on device @ blob.c/OpenBlob/2480.

There is ample disk space for this. Calculating 16.7 million X 222 bytes per image = ~4.175 GIG. The script fails with more than 19 GIG of disk space still open.

Does IM try to keep all of the process in memory? Is there another cause for this kind of error?

Re: Running out of space...or not

Posted: 2013-07-10T06:34:03-07:00
by magick
Check your /tmp partition. Its running out of disk space. Use the MAGICK_TMPDIR environment variable to point ImageMagick to a different partition for free space. Add -debug cache to the command line to track the temporary file resource requirements.

Re: Running out of space...or not

Posted: 2013-07-10T06:44:08-07:00
by farbewerk
Thanks for the quick reply! I saw that it's possible to do this with:

Code: Select all

putenv("MAGICK_TMPDIR=/data");
Do I use this in a general terminal session or do I need to declare this in the script itself?

Re: Running out of space...or not

Posted: 2013-07-10T06:48:55-07:00
by magick
Add it to your script. Make sure you have permissions to write to the partition.

Re: Running out of space...or not

Posted: 2013-07-10T07:23:53-07:00
by farbewerk
Getting this error:

Code: Select all

png-blast.sh: line 2: syntax error near unexpected token `"MAGICK_TMPDIR=/home/smcgown/PNGS"'
png-blast.sh: line 2: `putenv("MAGICK_TMPDIR=/home/smcgown/PNGS");'
The script currently reads:

Code: Select all

#! /usr/bin/sh
putenv("MAGICK_TMPDIR=/home/smcgown/PNGS");
list=$(cat newhexcodes.txt)
	for color in $list; do

	convert -size 2x2 xc:"#$color" $color.png

done
Is the putenv statement out of place?

Re: Running out of space...or not

Posted: 2013-07-10T08:31:36-07:00
by magick
In a shell script, its
  • export MAGICK_TMPDIR=/home/smcgown/PNGS

Re: Running out of space...or not

Posted: 2013-07-10T11:37:18-07:00
by farbewerk
Thank you very much. That worked perfectly.