Page 1 of 1

500 Internal Server Error when annotating

Posted: 2008-04-22T17:08:51-07:00
by mruwek
Hi,
I' ve noticed some strange issue. I' ve taken the button+text code from http://valokuva.org/

Code: Select all

<?php
/* Create a new Imagick object */
$im = new Imagick();
/* Create empty canvas */
$im->newImage( 200, 200, "white", "png" );
/* Create the object used to draw */
$draw = new ImagickDraw();
/* Set the button color.
 *    Changing this value changes the color of the button */
$draw->setFillColor( "#4096EE" );
/* Create the outer circle */
$draw->circle( 50, 50, 70, 70 );
/* Create the smaller circle on the button */
$draw->setFillColor( "white" );
/* Semi-opaque fill */
$draw->setFillAlpha( 0.2 );
/* Draw the circle */
$draw->circle( 50, 50, 68, 68 );
/* Set the font */
$draw->setFont( "./test1.ttf" );
/* This is the alpha value used to annotate */
$draw->setFillAlpha( 0.17 );
/* Draw a curve on the button with 17% opaque fill */
$draw->bezier( array(
array( "x" => 10 , "y" => 25 ),
array( "x" => 39, "y" => 49 ),
array( "x" => 60, "y" => 55 ),
array( "x" => 75, "y" => 70 ),
array( "x" => 100, "y" => 70 ),
array( "x" => 100, "y" => 10 ),
) );
/* Render all pending operations on the image */
$im->drawImage( $draw );
/* Set fill to fully opaque */
$draw->setFillAlpha( 1 );
/* Set the font size to 30 */
$draw->setFontSize( 30 );
/* The text on the */
$draw->setFillColor( "white" );
/* Annotate the text */
$im->annotateImage( $draw, 38, 55, 0, "go" );
/* Trim extra area out of the image */
$im->trimImage( 0 );
/* Output the image */
header( "Content-Type: image/png" );
echo $im;
?>
and it is not working. The result is 500 Internal Server Error: http://vcf.pl/imagickButton.php
Everything is ok when I remove the following parts of code:

Code: Select all

(…)
/* Set the font */
$draw->setFont( "./test1.ttf" );
(…)
/* Set the font size to 30 */
$draw->setFontSize( 30 );
(…)
/* Annotate the text */
$im->annotateImage( $draw, 38, 55, 0, "go" );
Now it renders ok but without a text of course: http://vcf.pl/imagickButtonOk.php

Any ideas what is the reason, and how to fix this?

Re: 500 Internal Server Error when annotating

Posted: 2008-04-23T10:49:23-07:00
by mkoppanen
Does test1.ttf exist?

Re: 500 Internal Server Error when annotating

Posted: 2008-04-23T13:01:04-07:00
by mruwek
Yes, of course. You can even download it ;)
http://vcf.pl/test1.ttf

Apart from that, when the font is missing, output should give something like this, instead of "Internal Server Error(…)":
Fatal error: Uncaught exception 'ImagickDrawException' with message 'The given font is not found in the ImageMagick configuration and the file (/xxx/xxx/xxx/test.ttf) is not accessible' in /xxx/xxx/xxx/imagick.php:18 Stack trace: #0 /home/jacek/www/imagick.php(18): ImagickDraw->setfont('/xxx/x...') #1 {main} thrown in /xxx/xxx/xxx/imagick.php on line 18

Re: 500 Internal Server Error when annotating

Posted: 2008-04-23T14:30:57-07:00
by mkoppanen
Is it possible to get a gdb backtrace out of that? Preferably with a debug build if possible. I can not reproduce it here.