|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59509 queryfontmetrics not respecting setresolution
Submitted: 2010-11-15 05:29 UTC Modified: 2010-11-21 06:58 UTC
From: george at sogetthis dot com Assigned:
Status: Closed Package: imagick (PECL)
PHP Version: 5.3.2 OS: -
Private report: No CVE-ID: None
 [2010-11-15 05:29 UTC] george at sogetthis dot com
If $im->SetResolution is used to set a resolution, queryfontmetrics doesn't respect the value. Changing the $print_resolution in the reproduce code doesn't affect the queryfontmetrics textWidth measurement, whereas the actual image dimension as calculated by drawImage'ing the data does.

Also, is the input to queryfontmetric point size or pixel height?

Reproduce code:
$print_resolution = 300;
$string = "Hello World";
$fontsize = 72;

$im = new Imagick();
$im->newImage(9040,3400, "white","png");

$draw = new ImagickDraw();
$data = $im->queryFontMetrics($draw, $string);

// draw image to test actual height
$draw->annotation(0, $data['ascender'] * ($print_resolution / 72), $string);

$dataii = $im->identifyimage();
print ":identifyimage height:" . $dataii['geometry']['height'];
print "<br/>-----------------------------<br/>";
print ":queryfontmetrics height: " . $data['textHeight'];

Expected result:
changing the $print_resolution gives different values from identifyimage, but the output to queryfontmetrics does not change.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-20 09:00 UTC] wizard at imagemagick dot org
Imagick is missing a method to set the drawing / annotation resolution. $im->setResolution() set the image resolution. Imagick needs a $draw->setResolution() method that sets the draw_info->density member. Since density is a string, you simply take the setResolution() float values and convert them to a string and assign it to the density member of the DrawInfo structure.
 [2010-11-20 20:37 UTC] george at sogetthis dot com
it looks like the api doesn't have a method to set the drawing / annotation density?
 [2010-11-21 06:38 UTC]
Seems like the PeekDrawingWand returns a copy of the DrawInfo structure. Currently the only way I can see is using PeekDrawingWand and allocating a new DrawingWand using DrawAllocateWand and the given draw_info.
 [2010-11-21 06:58 UTC]
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on

In case this was a website problem, the change will show
up on the website in short time.
Thank you for the report, and for helping us make PECL better.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Oct 02 20:05:56 2022 UTC