I use imagemagick convert PDF file to JPG , use PHP shell_exec('convert ./a.pdf ./a.jpg')
I get this error:
Error: /undefined in findresource Operand stack: --dict:15/24(L)-- F3 16.0 --dict:6/6(L)-- --dict:6/6(L)-- DroidSansFallback-UniGB-UTF16-H --dict:10/12(ro)(G)-- --nostringval-- CIDFontObject --dict:7/7(L)-- --dict:7/7(L)-- Adobe-GB1 Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1862 1 3 %oparray_pop 1861 1 3 %oparray_pop 1845 1 3 %oparray_pop --nostringval-- --nostringval-- 2 1 1 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- false 1 %stopped_push --nostringval-- %loop_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- %loop_continue Dictionary stack: --dict:1154/1684(ro)(G)-- --dict:1/20(G)-- --dict:75/200(L)-- --dict:75/200(L)-- --dict:106/127(ro)(G)-- --dict:286/300(ro)(G)-- --dict:22/25(L)-- --dict:4/6(L)-- --dict:26/40(L)-- Current allocation mode is local Last OS error: 2
Command in console is ok.
The answer is almost certainly related to the PATH
- either to convert
or ghostscript
(which is required for the PDF
aspect).
Try the following, which doesn't require ghostscript
:
shell_exec('convert a.jp b.jpg');
If that works, it's the PATH
to ghostscript
that is wrong.
If it doesn't work, it is the PATH
to convert
which is wrong, or the script is not getting executed in the folder you think it is.
As you state in the comments, the following actually solves the problem:
putenv("PATH=/usr/local/bin");