Rubblewebs

THESE CODES ARE PROVIDED FOR AN EXAMPLE OF HOW TO USE IMAGEMAGICK WITH PHP. CARE SHOULD BE TAKEN WHEN ACCEPTING USER INPUT.

I TAKE NO RESPONSABILTY FOR ANY PROBLEMS THAT MAY OCCURE WHEN USING ANY OF THIS CODE.

IT IS UP TO YOU TO SECURE THE CODE AND VALIDATE USER INPUT.

Imagick Draw functions page: 2

Set fill color

Sets the fill color to be used for drawing filled objects

Set fill color example
$im = new Imagick();
$im->newImage( 200, 150, 'NavajoWhite' );
$draw = new ImagickDraw();
$draw->setFillColor('Blue');
$draw->setStrokeColor( 'Black' );
$draw->setStrokeWidth(1); 
$draw->circle( 100, 75, 100, 10 );
$im->drawImage( $draw );
$im->writeImage('setFillColor.jpg'); 
$im->destroy();

( Later versions accept the color as a string. )

Set font

Sets the fully-specified font to use when annotating with text.

Set font example
$im = new Imagick();
$im->newImage( 200, 150, 'NavajoWhite' );
$draw = new ImagickDraw();
$draw->setFillColor( 'Black' );
$draw->setFont ( 'handsean.ttf' );
$draw->setFontSize ( 30 );
$draw->setGravity (Imagick::GRAVITY_CENTER);
$draw->annotation( 0, 0, 'Rubblewebs');
$im->drawImage( $draw );
$im->writeImage('setFont.jpg'); 
$im->destroy();

Set font size

Sets the font pointsize to use when annotating with text

Set font size example
$im = new Imagick();
$im->newImage( 200, 150, 'NavajoWhite' );
$draw = new ImagickDraw();
$draw->setFillColor( 'Black' );
$draw->setFont ( 'handsean.ttf' );
$draw->setFontSize ( 25 );
$draw->setGravity (Imagick::GRAVITY_NORTH);
$draw->annotation( 0, 0, 'Rubblewebs');
$draw->setFontSize ( 30 );
$draw->setGravity (Imagick::GRAVITY_CENTER);
$draw->annotation( 0, 0, 'Rubblewebs');
$draw->setFontSize ( 35 );
$draw->setGravity (Imagick::GRAVITY_SOUTH);
$draw->annotation( 0, 0, 'Rubblewebs');
$im->drawImage( $draw );
$im->writeImage('setFontSize.jpg'); 
$im->destroy();

Set gravity

Sets the text placement gravity to use when annotating with text.

Set gravity example
$im = new Imagick();
$im->newImage( 200, 150, 'NavajoWhite' );
$draw = new ImagickDraw();
$draw->setFillColor( 'Black' );
$draw->setFont ( 'handsean.ttf' );
$draw->setFontSize ( 30 );
$draw->setGravity (Imagick::GRAVITY_SOUTH);
$draw->annotation( 0, 0, 'Rubblewebs');
$im->drawImage( $draw );
$im->writeImage('setGravity.jpg'); 
$im->destroy();

Set stroke color

Sets the color used for stroking object outlines

Set stroke color example
$im = new Imagick();
$im->newImage( 200, 150, 'NavajoWhite' );
$draw = new ImagickDraw();
$draw->setFillColor('Blue');
$draw->setStrokeColor( 'Red' );
$draw->setStrokeWidth(5); 
$draw->circle( 100, 75, 100, 10 );
$im->drawImage( $draw );
$im->writeImage('setStrokeColor.jpg'); 
$im->destroy();

Set stroke width

Sets the width of the stroke used to draw object outlines

Set stroke width example
$im = new Imagick();
$im->newImage( 200, 150, 'NavajoWhite' );
$draw = new ImagickDraw();
$draw->setFillColor('Blue');
$draw->setStrokeColor( 'Black' );
$draw->setStrokeWidth(5); 
$draw->circle( 100, 75, 100, 10 );
$im->drawImage( $draw );
$im->writeImage('setStrokeWidth.jpg'); 
$im->destroy();

Set text antialias

Controls whether text is antialiased

Set text antialias example
$im = new Imagick();
$im->newImage( 200, 150, 'NavajoWhite' );
$draw = new ImagickDraw();
$draw->setFillColor( 'Black' );
$draw->setFont ( 'handsean.ttf' );
$draw->setFontSize ( 30 );
$draw->setTextAntialias( FALSE );
$draw->setGravity (Imagick::GRAVITY_CENTER);
$draw->annotation( 0, 0, 'Rubblewebs');
$im->drawImage( $draw );
$im->writeImage('setTextAntialias.jpg'); 
$im->destroy();

( Text is antialiased by default. )

Set text decoration

Specifies a decoration to be applied when annotating with text.

Set text decoration example
$im = new Imagick();
$im->newImage( 200, 150, 'NavajoWhite' );
$draw = new ImagickDraw();
$draw->setFillColor( 'Black' );
$draw->setFont ( 'handsean.ttf' );
$draw->setFontSize ( 30 );
$draw->setGravity (Imagick::GRAVITY_CENTER);
$draw->setTextDecoration( 2 );
$draw->annotation( 0, 0, 'Rubblewebs');
$im->drawImage( $draw );
$im->writeImage('setTextDecoration.jpg'); 
$im->destroy();

( 1 - Text will be normal
2 - Underline
3 - Upperline
4 - Stroke-through
The line is not black - tried adding a stroke color and the line is now black but the text has a stroke! )