CodeIgniter Forums
Cannot generate image preview using Servicess:image - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Cannot generate image preview using Servicess:image (/showthread.php?tid=79207)



Cannot generate image preview using Servicess:image - sfarzoso - 05-11-2021

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?


RE: Cannot generate image preview using Servicess:image - InsiteFX - 05-11-2021

This has nothing to do with CodeIgniter.


RE: Cannot generate image preview using Servicess:image - iRedds - 05-11-2021

Codeigniter "imagic" != Imagic
Use Imagic directly


RE: Cannot generate image preview using Servicess:image - sfarzoso - 05-12-2021

there is an example about imagick in codeigniter?


RE: Cannot generate image preview using Servicess:image - InsiteFX - 05-12-2021

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.


RE: Cannot generate image preview using Servicess:image - demyr - 02-04-2022

(05-12-2021, 02:01 AM)InsiteFX Wrote: 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.

Any idea about how to set this path? I feel like the documentation lacks this information.


RE: Cannot generate image preview using Servicess:image - InsiteFX - 02-04-2022

This is the only thing I can find on it plus php.net links are in the bottom link.

How do I set the path in Apache for ImageMagick so I can run from PHP system()?