Topic: Fatal Error

Hello i'm doing a test with following code

<?php

error_reporting(E_ALL);
ini_set( 'display_errors','1');

/* Create a new imagick object */
$im = new Imagick();

/* Create new image. This will be used as fill pattern */
$im->newPseudoImage(50, 50, "gradient:red-black");

/* Create imagickdraw object */
$draw = new ImagickDraw();

/* Start a new pattern called "gradient" */
$draw->pushPattern('gradient', 0, 0, 50, 50);

/* Composite the gradient on the pattern */
$draw->composite(Imagick::COMPOSITE_OVER, 0, 0, 50, 50, $im);

/* Close the pattern */
$draw->popPattern();

/* Use the pattern called "gradient" as the fill */
$draw->setFillPatternURL('#gradient');

/* Set font size to 52 */
$draw->setFontSize(52);

/* Annotate some text */
$draw->annotation(20, 50, "Hello World!");

/* Create a new canvas object and a white image */
$canvas = new Imagick();
$canvas->newImage(350, 70, "white");

/* Draw the ImagickDraw on to the canvas */
$canvas->drawImage($draw);

/* 1px black border around the image */
$canvas->borderImage('black', 1, 1);

/* Set the format to PNG */
$canvas->setImageFormat('png');

/* Output the image */
header("Content-Type: image/png");
echo $canvas;
?>

The output of this script should be this: https://imgur.com/Qn0K7qC

However i got the following error

Fatal error: Uncaught ImagickException: non-conforming drawing primitive definition `text' @ error/draw.c/RenderMVGContent/4466 in /home/andrea/domains/domain.it/public_html/test/magick.php:38 Stack trace: #0 /home/andrea/domains/domain.it/public_html/test/magick.php(38): Imagick->drawImage(Object(ImagickDraw)) #1 {main} thrown in /home/andrea/domains/domain.it/public_html/test/magick.php on line 38

PHP Version is PHP Version 7.4.27
Imagick version is 3.5.1

Thanks for any kind of help

Re: Fatal Error

Distro ? version ? arch ?

List of installed php packages and ImageMagick6 or ImageMagick7 version ?

also "php --ri imagick"

imagick

imagick module => enabled
imagick module version => 3.7.0
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 7.1.0-19 Q16-HDRI x86_64 2021-12-22 https://imagemagick.org
Imagick using ImageMagick library version => ImageMagick 7.1.0-19 Q16-HDRI x86_64 2021-12-22 https://imagemagick.org
...
Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Fatal Error

I'm not able to reproduce on my Fedora 35 workstation (bot using im6 or im7)

I'm not able to reproduce on CentOS 8 Stream using php-pecl-imagick-im6 version 3.7.0

I was able to reproduce on CentOS 8 Stream using php-pecl-imagick-im7 version 3.7.0, need to understand what have changed.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Fatal Error

This seems related to default font

Setting explicitly the font to use fix this issue


/* Set font */
$draw->setFont("/usr/share/fonts/liberation-sans/LiberationSans-Italic.ttf");
Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Fatal Error

Setting a font seems mandatory, also used in imagick test suite
https://github.com/Imagick/imagick/comm … f6769043fa

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Fatal Error

Installing "open-sans-fonts" also solves this (Open-Sans-Regular being used by default)

I will make it a  dependency of the ImageMagick6/7 packages

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Fatal Error

Hello! thanks for all suggestion
I installed open-sans-fonts but still not working https://ibb.co/X7nj5T0
i see always the fatal error

Re: Fatal Error

Here you can see the phpinfo() https://test.thermics-energie.it/test.php

Re: Fatal Error

Here you can see also "php --ri imagick"
https://ibb.co/xGrG0Mm

Re: Fatal Error

In the end i have CentOS Linux release 7.9.2009 (Core)
Let me know if have to provide something else..
Thank you!

Re: Fatal Error

Sorry cannot reproduce on CentOS 7 using im6 or im7 (where fonts are installed)

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Fatal Error

Tested from command line... (if you test from web... perhaps have to restart the services)

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Fatal Error

Okay i already reboot server
Is this the correct folder path for font? /usr/share/fonts/open-sans/
https://ibb.co/S6qjNWn

14 (edited by fabioweb 2022-01-20 12:59:31)

Re: Fatal Error

If i try to add also your suggested code
$draw->setFont("/usr/share/fonts/open-sans/OpenSans-Regular.ttf");

i got

Fatal error: Uncaught ImagickException: non-conforming drawing primitive definition `text' @ error/draw.c/RenderMVGContent/4466 in /home/andrea/domains/thermics-energie.it/public_html/test/magick.php:42 Stack trace: #0 /home/andrea/domains/thermics-energie.it/public_html/test/magick.php(42): Imagick->drawImage(Object(ImagickDraw)) #1 {main} thrown in /home/andrea/domains/thermics-energie.it/public_html/test/magick.php on line 42

Re: Fatal Error

You should really learn to use command line.....

# rpm -ql open-sans-fonts
...
Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

16 (edited by fabioweb 2022-01-20 13:00:54)

Re: Fatal Error

yes installed font with command line. I did with
# yum install open-sans-fonts

Re: Fatal Error

> Notice: Undefined variable: draw in /home/andrea/domains/thermics-energie.it/public_html/test/magick.php on line 6

no comment....
you should also learn PHP

sorry, but I don't think I can't really help more on this issue, which is explained and fixed for me

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi