• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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

#2
This has nothing to do with CodeIgniter.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
Codeigniter "imagic" != Imagic
Use Imagic directly
Reply

#4
there is an example about imagick in codeigniter?
Reply

#5
If using the ImageMagick library, you must set the path to the library on your server in app/Config/Images.php.

Note

The ImageMagick handler does NOT require the imagick extension to be loaded on the server.
As long as your script can access the library and can run exec() on the server, it should work.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.