issue - bending text using imagick api

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
iscripts
Posts: 6
Joined: 2011-10-20T22:14:23-07:00
Authentication code: 8675308

issue - bending text using imagick api

Post 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..
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: issue - bending text using imagick api

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply