Welcome Guest, Not a member yet? Register   Sign In
Cannot generate image preview using Servicess:image
#1

I'm trying to implement this solutiion How do I convert a PDF document to a preview image in PHP? - Stack Overflow

Essentially the user says that is possible create a preview of a pdf based on this code:

PHP Code:
<?php
$im 
= new imagick('file.pdf[0]');
$im->setImageFormat('jpg');
header('Content-Type: image/jpeg');
echo 
$im;
?>

so I tried to convert that code using the image service included in CodeIgniter 4:


PHP Code:
$im = \Config\Services::image('imagick');
        $im->withFile(ROOTPATH 'public/uploads/media/2021/05/2.pdf');
        $im->save(ROOTPATH 'public/uploads/media/2021/05/2.jpg');
        echo $im

and I got: The file is not a supported image type.

how is that possible?
Reply


Messages In This Thread
Cannot generate image preview using Servicess:image - by sfarzoso - 05-11-2021, 08:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB