A
A
Anton2016-09-14 21:18:02
Laravel
Anton, 2016-09-14 21:18:02

How to make Imagick, ImagickDraw, etc. work. in Laravel?

Hello!
Can you please tell me how to work with these classes in Laravel?
use Imagick etc. Does not help. All the same writes that such class is not found.
Piece of code:

$draw = new ImagickDraw();

$strokeColor = new ImagickPixel('rgb(0, 0, 0)');
$fillColor = new ImagickPixel('DodgerBlue2');

$draw->setStrokeOpacity(1);
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);

$draw->setStrokeWidth(2);
$draw->setFontSize(72);

$draw->circle(50, 50, 100, 100);

$imagick = new Imagick();
$imagick->newImage(500, 500, new ImagickPixel('transparent'));
$imagick->setImageFormat("png");
$imagick->drawImage($draw);

header("Content-Type: image/png");
echo $imagick->getImageBlob();

Above in this controller:
use Imagick;
use ImagickDraw;
use ImagickPixel;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2016-09-14
@Sanasol

apt-get install php5-gd
This should be installed separately from pecl.
php.net/manual/en/imagick.installation.php

V
Vitaliy Jakim, 2017-12-16
@Jakim

use Imagick;
use ImagickDraw;
use ImagickPixel;

This is generally nonsense
1) phpinfo(); look at the Imagick
item there If not, look at the extension=php_imagick.dll line in php.ini if ​​not, add to the end of the list of all extensions (you can’t go wrong there) 2) If there is an error when starting the server (look in the logs) that there is no .dll library, then we download the library of the dll file from here , there we select the version of php that you use and that bit depth, again, you can see it in phpinfo (); 3) In the downloaded archive, look for php_imagick.dll and put it in the folder php/PHP-YOUR_VERSION/ext RESTART THE SERVER!!! if after that there are problems and errors, write in the comments, we will figure it out
And indicate which server you have, the name of the program.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question