Page 1 of 1

issue - bending text using imagick api

Posted: 2012-12-18T05:21:49-07:00
by iscripts
hello guys..

im using imagick api to generate bent texts. it works ok on some occasions, but with some of the fonts, the bending goes berserk. here is the code snippet:-

Code: Select all

$image  = new Imagick();
$draw   = new ImagickDraw();
$pixel  = new ImagickPixel('gray');

$draw->setGravity(imagick::GRAVITY_CENTER);
$draw->setFont($this->font); //use any font here
$draw->setFillColor("#000000");
$draw->setFontSize(20);
$draw->setTextAntialias(false);

$metrics = $image->queryFontMetrics($draw, 'ANIMATIONS');
$bound_width = $metrics['textWidth'];
$bound_height = $metrics['textHeight'];
$image->newImage($bound_width,$bound_height,$pixel);

$image->annotateImage($draw, 0, 0, 0, 'ANIMATIONS');
$image->trimImage(0); 
$image->paintTransparentImage('gray', 0.0, 10);

$txtCurve = array();
$txtCurve[] = (int)$this->curve;
$image->distortImage( Imagick::DISTORTION_ARC, 220, false );

$image->setImageFormat('png');
ob_start();
header("Content-type: image/png");
echo $image;


here is the output i get:-

Image

can anyone point out what i am doing wrong here?

thanks..

Re: issue - bending text using imagick api

Posted: 2012-12-18T16:03:20-07:00
by anthony
Set the appropriate virtual-pixel setting. The default setting for referencing pixels outside the image proper, is 'edge' which means anything touching the edge gets replicated out to infinity.

See Virtual Pixel setting
http://www.imagemagick.org/Usage/misc/#virtual-pixel

Also see, Arc into Full Rings
http://www.imagemagick.org/Usage/distorts/#arc_rings