0

I'm trying to get it to work using PHP on Hostinger.

I have tried the following:

$white=new Imagick($fichero["tmp_name"]); $white->setImageFormat('jpg'); $nombre = explode(".", $fichero["name"]); $white->writeImage($path.$nombre[0].'.jpg'); $white->clear(); $white->destroy();

It tells me Ghostscript is missing. Ok, then i try to launch it by exec:

exec("convert -density 150 '".$pathPdf.$fichero["name"]."' -quality 90 output-%3d.jpg 2>&1";

Convert prints:

Array ( [0] => sh: convert: command not found )

exec("gm convert '".$pathPdf.$fichero["name"]."' '".$pathPdf."testing-%3d.jpg' 2>&1",$asd);

GM prints:

Array ( \[0\] =\> execvp failed, errno = 2 (No such file or directory) \[1\] =\> gm convert: "gs" "-q" "-dBATCH" "-dSAFER" "-dMaxBitmap=50000000" "-dNOPAUSE" "-sDEVICE=ppmraw" "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4" "-r72x72" "-sOutputFile=/tmp/gmVkgulI" "--" "/tmp/gmbA23ic" "-c" "quit". \[2\] =\> gm convert: Postscript delegate failed (/home/u227315269/domains/pruebasivan.online/public_html/prueba/mediaUsuarios/1/4/certificado.pdf). )

An idea to be able to convert a pdf in Hostinger to images?

Thanks in advance

MaartenDev
  • 5,631
  • 5
  • 21
  • 33
  • Are you sure that hostinger has imagick installed? Did you try running it from a SSH session? – MaartenDev Apr 01 '22 at 10:50
  • ImageMagick delegates PDF rendering to Ghostscript (as it does for PostScript). It may be possible to specify a different delegate if you have one, otherwise you need to install Ghostscript. – KenS Apr 01 '22 at 11:08
  • I can't access ssh, it's a host service, Imagick is there but no ghostscript – Ivan Rodríguez Apr 01 '22 at 11:20
  • Well without Ghostscript ImagMagick can't render PDF files (or PostScript files). BTW this doesn't seem to be a crash, you seem to be getting perfectly reasonable error messages telling you what's wrong. – KenS Apr 01 '22 at 13:33

0 Answers0