Page 1 of 1

Convert, Tmp Disk Space, and Last OS error:28

Posted: 2010-03-11T06:31:23-07:00
by zi94sm65
I developed a php application running on a shared webserver environment that utilizes the Imagemagick convert command to convert multi-page pdf files into jpg.

The pdf file size is typically between 3MB-12MB and contains 15-25 pages of 8.5"X11" scanned documents at 300dpi.

The convert commands works for the first three pdf documents and then every file after that it keeps dropping the last few pages and the last jpg image it generates is black.

Further, investigation reveals an error code of "Last OS error: 28" with the full error looking like:

Code: Select all

ERROR: /ioerror in --.outputpage-- Operand stack: 1 true Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1 3 %oparray_pop 1 3 %oparray_pop 1 3 %oparray_pop --nostringval-- --nostringval-- 21 1 20 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- 0 9 %oparray_pop --nostringval-- --nostringval-- Dictionary stack: --dict:1128/1686(ro)(G)-- --dict:0/20(G)-- --dict:107/200(L)-- --dict:107/200(L)-- --dict:104/127(ro)(G)-- --dict:241/347(ro)(G)-- --dict:20/24(L)-- --dict:4/6(L)-- --dict:21/32(L)-- Current allocation mode is local Last OS error: 28 Last OS error: 28
After doing some googling on the matter, this all seems to boil down to not enough temporary disk space available for Imagemagick.

My webserver says it has this much tmp space available to Imagemagick:

Code: Select all

AREA = 12kb
MEMORY = 7.9gb
MAP = 5.9gb
DISK = 32gb4eb
When i asked my webhost the first time about the status of the tmp directory they said it was, "pretty full", and said they cleaned it out and to try again. Once again, convert worked for a couple of documents then started giving me the not enough memory error. I asked my webhost a second time about the status of the tmp directory and they said it was about 50% full and told me to set the tmp directory for Imagemagick to the tmp directory associated with my user account and to quit using the server's system-wide tmp directory.

How can i set what tmp directory Imagemagick uses? Is there a command i can use? Or is that only something the webserver administrators: my webhost can set and they are basically telling me to buzz-off? Plus, if my user account was only given 20,000mb won't that make the situation worse instead of better?

The convert command i am using to do the pdf->jpg is:

Code: Select all

$cmd = 'convert -limit memory 1024 -limit map 4096 -density 300x300 -define pdf:use-cropbox=true ' . $pdf_file . ' -resize 35% -quality 100 ' . $jpgloc;
$status=exec($cmd);
Could my convert command be written better to free-up space after it is done writing the jpg for each page somehow? The pdf files contain some really fine print so i don't think i can go much lower than 300dpi, but any help or suggestions would be welcome at this point!

Re: Convert, Tmp Disk Space, and Last OS error:28

Posted: 2010-03-15T07:48:30-07:00
by zi94sm65
UPDATE: Using
convert -debug Resource -limit memory 1 -limit map 1 -density 300x300 -define pdf:use-cropbox=true
i was able to get the server to give me information. Can anybody explain to me what is going on with the memory?

Code: Select all

09:09:32 0:01 0.000u 6.2.8 Resource convert[20030]: resource.c/AcquireUniqueFileResource/395/Resource /tmp/magick-XX8U2GNo 
09:09:32 0:01 0.000u 6.2.8 Resource convert[20030]: resource.c/RelinquishUniqueFileResource/835/Resource /tmp/magick-XX8U2GNo
09:09:33 0:01 0.150u 6.2.8 Resource convert[20030]: resource.c/AcquireUniqueFileResource/395/Resource /tmp/magick-XXWb5I9A 
09:09:33 0:01 0.150u 6.2.8 Resource convert[20030]: resource.c/AcquireUniqueFileResource/395/Resource /tmp/magick-XX8UTUvN 
09:09:41 0:10 8.590u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 63mb/63mb/7.9gb 
09:09:41 0:10 8.590u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Memory: 63mb/63mb/1e+03kb 
09:09:41 0:10 8.590u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Memory: 63mb/0/1e+03kb 
09:09:41 0:10 8.590u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Disk: 63mb/63mb/4eb 
09:09:41 0:10 8.590u 6.2.8 Resource convert[20030]: resource.c/AcquireUniqueFileResource/395/Resource /tmp/magick-XXm7awXl 
09:09:41 0:10 8.590u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource File: 0/0/12kb 
09:09:41 0:10 8.740u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 63mb/63mb/7.9gb 
09:09:41 0:10 8.740u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Map: 63mb/63mb/1e+03kb 
09:09:41 0:10 8.740u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Map: 63mb/0/1e+03kb 
09:09:41 0:10 8.930u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 79mb/79mb/7.9gb 
09:09:41 0:10 8.930u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Memory: 79mb/79mb/1e+03kb 
09:09:41 0:10 8.930u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Memory: 79mb/0/1e+03kb 
09:09:41 0:10 8.930u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Disk: 79mb/1.4e+02mb/4eb 
09:09:41 0:10 8.930u 6.2.8 Resource convert[20030]: resource.c/AcquireUniqueFileResource/395/Resource /tmp/magick-XXbCYeiV 
09:09:41 0:10 8.930u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource File: 0/2/12kb 
09:09:42 0:10 9.120u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 79mb/79mb/7.9gb 
09:09:42 0:10 9.120u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Map: 79mb/79mb/1e+03kb 
09:09:42 0:10 9.120u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Map: 79mb/0/1e+03kb 
09:09:42 0:11 9.360u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 79mb/79mb/7.9gb 
09:09:42 0:11 9.360u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Memory: 79mb/79mb/1e+03kb 
09:09:42 0:11 9.360u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Memory: 79mb/0/1e+03kb 
09:09:42 0:11 9.360u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Disk: 79mb/2.2e+02mb/4eb 
09:09:42 0:11 9.360u 6.2.8 Resource convert[20030]: resource.c/AcquireUniqueFileResource/395/Resource /tmp/magick-XXyvjOKv 
09:09:42 0:11 9.360u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource File: 0/2/12kb 
09:09:42 0:11 9.530u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 79mb/79mb/7.9gb 
09:09:42 0:11 9.530u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Map: 79mb/79mb/1e+03kb 
09:09:42 0:11 9.530u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Map: 79mb/0/1e+03kb 
09:09:42 0:11 9.780u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 79mb/79mb/7.9gb 
09:09:42 0:11 9.780u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Memory: 79mb/79mb/1e+03kb 
09:09:42 0:11 9.780u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Memory: 79mb/0/1e+03kb 
09:09:42 0:11 9.780u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Disk: 79mb/3e+02mb/4eb 
09:09:42 0:11 9.780u 6.2.8 Resource convert[20030]: resource.c/AcquireUniqueFileResource/395/Resource /tmp/magick-XXpA0rk7 
09:09:42 0:11 9.780u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource File: 0/4/12kb 
09:09:42 0:11 9.950u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 79mb/79mb/7.9gb 
09:09:42 0:11 9.950u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Map: 79mb/79mb/1e+03kb 
09:09:42 0:11 9.950u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Map: 79mb/0/1e+03kb 
09:09:43 0:11 10.200u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 79mb/79mb/7.9gb 
09:09:43 0:11 10.200u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Memory: 79mb/79mb/1e+03kb 
09:09:43 0:11 10.200u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Memory: 79mb/0/1e+03kb 
09:09:43 0:11 10.200u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Disk: 79mb/3.8e+02mb/4eb 
09:09:43 0:11 10.200u 6.2.8 Resource convert[20030]: resource.c/AcquireUniqueFileResource/395/Resource /tmp/magick-XXmkEM0J 
09:09:43 0:11 10.200u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource File: 0/4/12kb 
09:09:43 0:12 10.370u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 79mb/79mb/7.9gb 
09:09:43 0:12 10.370u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Map: 79mb/79mb/1e+03kb 
09:09:43 0:12 10.370u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Map: 79mb/0/1e+03kb 
09:09:43 0:12 10.620u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 79mb/79mb/7.9gb 
09:09:43 0:12 10.620u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Memory: 79mb/79mb/1e+03kb 
09:09:43 0:12 10.620u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Memory: 79mb/0/1e+03kb 
09:09:43 0:12 10.620u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Disk: 79mb/4.6e+02mb/4eb 
09:09:43 0:12 10.620u 6.2.8 Resource convert[20030]: resource.c/AcquireUniqueFileResource/395/Resource /tmp/magick-XX2AtvNn 
09:09:43 0:12 10.620u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource File: 0/6/12kb 
09:09:43 0:12 10.800u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 79mb/79mb/7.9gb 
09:09:43 0:12 10.800u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Map: 79mb/79mb/1e+03kb 
09:09:43 0:12 10.800u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Map: 79mb/0/1e+03kb 
09:09:43 0:12 11.040u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Area: 79mb/79mb/7.9gb 
09:09:43 0:12 11.040u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Memory: 79mb/79mb/1e+03kb 
09:09:43 0:12 11.040u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Memory: 79mb/0/1e+03kb 
09:09:43 0:12 11.040u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource Disk: 79mb/5.4e+02mb/4eb 
09:09:43 0:12 11.040u 6.2.8 Resource convert[20030]: resource.c/AcquireUniqueFileResource/395/Resource /tmp/magick-XXg3A1G2 
09:09:43 0:12 11.040u 6.2.8 Resource convert[20030]: resource.c/AcquireMagickResource/216/Resource File: 0/6/12kb 
09:09:44 0:12 11.110u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource File: 0/6/12kb 
09:09:44 0:12 11.110u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Disk: 63mb/4.7e+02mb/4eb
09:09:44 0:12 11.110u 6.2.8 Resource convert[20030]: resource.c/RelinquishUniqueFileResource/835/Resource /tmp/magick-XXm7awXl
09:09:44 0:13 11.170u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource File: 0/4/12kb 
09:09:44 0:13 11.170u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Disk: 79mb/3.9e+02mb/4eb
09:09:44 0:13 11.170u 6.2.8 Resource convert[20030]: resource.c/RelinquishUniqueFileResource/835/Resource /tmp/magick-XXbCYeiV
09:09:44 0:13 11.230u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource File: 0/4/12kb 
09:09:44 0:13 11.230u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Disk: 79mb/3.1e+02mb/4eb
09:09:44 0:13 11.230u 6.2.8 Resource convert[20030]: resource.c/RelinquishUniqueFileResource/835/Resource /tmp/magick-XXyvjOKv
09:09:44 0:13 11.280u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource File: 0/2/12kb 
09:09:44 0:13 11.280u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Disk: 79mb/2.4e+02mb/4eb
09:09:44 0:13 11.280u 6.2.8 Resource convert[20030]: resource.c/RelinquishUniqueFileResource/835/Resource /tmp/magick-XXpA0rk7
09:09:44 0:13 11.340u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource File: 0/2/12kb 
09:09:44 0:13 11.340u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Disk: 79mb/1.6e+02mb/4eb
09:09:44 0:13 11.340u 6.2.8 Resource convert[20030]: resource.c/RelinquishUniqueFileResource/835/Resource /tmp/magick-XXmkEM0J
09:09:44 0:13 11.390u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource File: 0/0/12kb 
09:09:44 0:13 11.390u 6.2.8 Resource convert[20030]: resource.c/RelinquishMagickResource/801/Resource Disk: 79mb/79mb/4eb 
09:09:44 0:13 11.390u 6.2.8 Resource convert[20030]: resource.c/RelinquishUniqueFileResource/835/Resource /tmp/magick-XX2AtvNn
09:09:44 0:13 11.450u 6.2.8 Resource convert[20030]: resource.c/RelinquishUniqueFileResource/835/Resource /tmp/magick-XXWb5I9A
09:09:44 0:13 11.450u 6.2.8 Resource convert[20030]: resource.c/RelinquishUniqueFileResource/835/Resource /tmp/magick-XX8UTUvN
09:09:44 0:13 11.470u 6.2.8 Resource convert[20030]: resource.c/RelinquishUniqueFileResource/835/Resource /tmp/magick-XX8U2GNo
convert: Memory allocation failed `/tmp/magick-XX8UTUvN'. convert: Postscript
delegate failed

Re: Convert, Tmp Disk Space, and Last OS error:28

Posted: 2010-03-15T08:02:49-07:00
by magick
Multi-page PDF files can consume lots of memory and / or disk. Set the environment variable MAGICK_TMPDIR and point it to an area of your disk with plenty of free space. Regarding how ImageMagick deals with memory / disk, see http://www.imagemagick.org/script/archi ... .php#cache.