We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Can I use Phalcons Imagick with file_get_contents?

Hello. Tell me please, can I use Phalcon's Imagick with file_get_contents? Or only php-imagick?



1.4k
Accepted
answer

Phalcon Imagick class gets at the entrance file . file_get_contents reads entire file into a string. So you need return file from a string with correctly headers. You can use base64 format. Maybe like this:

$file = 'https://you/file/path.jpg';
$data = base64_encode(file_get_contents($file));

$image = new \Phalcon\Image\Adapter\Imagick( 'data: '.mime_content_type($file).';base64,'.$data);
...