php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71626 gmagick extension works only twice via PHP FPM
Submitted: 2016-02-18 16:26 UTC Modified: 2016-02-19 12:14 UTC
From: maximilian dot bloch at gmail dot com Assigned: danack (profile)
Status: Closed Package: gmagick (PECL)
PHP Version: 5.6.18 OS: Ubuntu 15.10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: maximilian dot bloch at gmail dot com
New email:
PHP Version: OS:

 

 [2016-02-18 16:26 UTC] maximilian dot bloch at gmail dot com
Description:
------------
The below code fails via nginx+php-fpm after the second try. It works the first two tries only. If I restart|reload php-fpm, the script works again, exactly two consecutive times, then it fails again.

I am running gmagick-1.1.7RC3

I have tried tweaking some php-fpm settings with no effect.

I have tried several fonts with the same results.

php-cli work just fine.

I disabled the imagick extension with the same results, so I do not see a conflict here.

Thanks for your help.

Test script:
---------------
<?php
$image = new Gmagick();
$fontDraw = new GmagickDraw();
$fontDraw->setFont('./RNS.ttf');
$fontDraw->setFontSize(72);
$fontMetrics = $image->queryFontMetrics($fontDraw, 'g');
print_r($fontMetrics);
// EOF

Expected result:
----------------
Array ( [characterWidth] => 72 [characterHeight] => 72 [ascender] => 71 [descender] => -32 [textWidth] => 36 [textHeight] => 103 [maximumHorizontalAdvance] => 61 ) 

Actual result:
--------------
Fatal error: Uncaught exception 'GmagickException' with message 'Wand contains no images `%.1024s (MagickWand-2)' in test.php:6 Stack trace: #0 test.php(6): Gmagick->queryfontmetrics(Object(GmagickDraw), 'g') #1 {main} thrown in test.php on line 6

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-19 02:03 UTC] danack@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: danack
 [2016-02-19 02:03 UTC] danack@php.net
I can reproduce inside a single script with the code below.


There is a very good chance that the bug is that it works at all - looking at the code, queryFontMetrics is not meant to work if there are no images associated with the Gmagick object. i.e. it is likely the bug fix will to make it consistently fail for this code.


for ($i=0; $i<5; $i++) {
	$image = new Gmagick();
	$fontDraw = new GmagickDraw();
	$fontMetrics = $image->queryFontMetrics($fontDraw, 'g');
	var_dump($fontMetrics);
}
 [2016-02-19 12:14 UTC] danack@php.net
-Status: Verified +Status: Closed
 [2016-02-19 12:14 UTC] danack@php.net
This should be fixed in the next release of Gmagick.

As a workaround, you should be able to call it safely on any Gmagick object that contains an image. So either one of the images you're actually processing or a built-in one like "$gmagick = new \Gmagick("magick:logo");"
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 10:01:31 2024 UTC