How can I install ghostscript to work with PHP and imagegick so I can convert pdf files to png images

7k Views Asked by At

Ok , I'm really confused .. I installed Imagemagick on XAMPP and it got installed successfully after running the phpinfo() function ... However , I'm not sure how to link ghostscript to PHP because I installed ghostscript on my computer and it's installed as a normal software having a UI like other programs on my desktop and I don't think that's how it's supposed to be ... How should I link it to PHP so imagemagick can detect it , like should I modify the apache file and php.ini .. if so , what should I put in there ? what exact file should should I download to install ghostscript ?

Thanks a bunch !!

1

There are 1 best solutions below

0
On

you can run both imagemagick and ghostscript as shell commands like this

for Ghostscript :

echo exec('gswin64 -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=d:\pdf\6.pdf -dBATCH '); 

For Imagemagick

echo exec('convert -colorspace sRGB -quality 195% ');

now you will have to search for the right parameters to covert PDFs,optimize and merge them and as @kens said you will use gswin32c.exe as a command shell and gswin32.exe to show the output in the GS tool it self