mercredi 27 novembre 2019

Using Imagick to convert PDF in landscape format to image but not working

i wanna convert pdf to image and i use imagick (installed imagick & ghostscript 9.26 on linux server) but have error:

PDFDelegateFailed `The system cannot find the file specified. ' @ error/pdf.c/ReadPDFImage/794

$uploadFile = $request->file('file');

    if ($uploadFile->getClientOriginalExtension() == FileFormat::PDF && $request->input('convert_to')) {
        $imagick = new \Imagick();
        if($imagick->getNumberImages()!=0)
        {
            $response->code = HttpStatusCode::UNPROCESSABLE_ENTITY;
            $response->error->add('converting have error.', 'Not convertible. Your file have more than 1 page.');
            return $response->json();
        }
        $imagick->setResolution(300, 300);
        $imagick->readImage(($uploadFile->getFileInfo())->getPathname());
        $imagick->setImageCompressionQuality(100);
        $imagick->setImageFormat($request->input('convert_to'));
        $extension = $request->input('convert_to');
        $fileType = $imagick->getImageMimeType();
    } 


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire