I'm unable to use Imagick in PHP to create images. The functions are all present, but functions that fill the Imagick
object have no effect.
Look at the following snippet:
<?php
$img = new Imagick();
$img->newImage(100, 80, new ImagickPixel("red"));
var_dump($img);
?>
The output is:
object(Imagick)#1 (0) {
}
And the output of var_dump($img->getSize())
is:
Array
(
[columns] => 0
[rows] => 0
)
So the point is that all those image creating functions I tested such as newImage($x, $y, $color)
, readImage($filename)
etc. have no effect at all, even though they claim to be successful by returning true
. The error output seems to report no errors. It all works fine in GD, but I want to switch to Imagick now because GD lacks functionality.
So what is the matter with this? Did I forget to set an environment variable, call a preparing function, or did I just fully misunderstand how to use Imagick in PHP?
Using newPseudoImage works.
<?php
$img = new Imagick();
$img->newPseudoImage(100, 80, "xc:red");
$img->setImageFormat('png');
var_dump($img->getSize());
echo $img->getImageBlob();
I have no idea why new image doesn't work - I've opened an issue for it, as your code not working is non-intuitive https://github.com/mkoppanen/imagick/issues/148