Running out of space...or not

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
farbewerk
Posts: 11
Joined: 2013-07-02T12:42:24-07:00
Authentication code: 6789

Running out of space...or not

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Running out of space...or not

Post 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.
farbewerk
Posts: 11
Joined: 2013-07-02T12:42:24-07:00
Authentication code: 6789

Re: Running out of space...or not

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Running out of space...or not

Post by magick »

Add it to your script. Make sure you have permissions to write to the partition.
farbewerk
Posts: 11
Joined: 2013-07-02T12:42:24-07:00
Authentication code: 6789

Re: Running out of space...or not

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Running out of space...or not

Post by magick »

In a shell script, its
  • export MAGICK_TMPDIR=/home/smcgown/PNGS
farbewerk
Posts: 11
Joined: 2013-07-02T12:42:24-07:00
Authentication code: 6789

Re: Running out of space...or not

Post by farbewerk »

Thank you very much. That worked perfectly.
Post Reply