Convert, Tmp Disk Space, and Last OS error:28
Posted: 2010-03-11T06:31:23-07:00
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:
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:
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:
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!
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
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
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);