imagesetthickness 


gd apg

SETS the thickness of the lines drawn when drawing rectangles, polygons, arcs etc.





This function returns TRUE on success or FALSE on failure.



<?php

bool imagesetthickness 
( GdImage $image, int $thickness )

where,

$image = The image identifier

$thickness 
= The thickness of the line

?>

  $image   


The image identifier.



  $thickness   


The thickness of a line, in pixels..



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';

$base_img = "png/baseXx.png";

$dest_file_img = 'png/PNG 066 01 imagesetthickness-f.png';

$id_tick1 = imagecreatefrompng($base_img);
$yellow   = imagecolorallocate($id_tick1, 250, 255, 0);
$blue     = imagecolorallocate($id_tick1, 0, 0, 180);
$red      = imagecolorallocate($id_tick1, 180, 0, 0);
$green    = imagecolorallocate($id_tick1, 0, 180, 0);
$tick_triangle = 5;
$tick_rectangle = 10;

/* - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
   antialias => is set to FALSE
   - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */

$antialiastick1 = imageantialias($id_tick1, FALSE);

$tick_triangle = 
imagesetthickness($id_tick1, $tick_triangle);
imagerectangle($id_tick1, 50, 50, 300, 250, $blue);

$tick_rectangle = 
imagesetthickness($id_tick1, $tick_rectangle);

$vertices_array = array(100, 100, 150, 200, 250, 75); 
imagepolygon($id_tick1, $vertices_array, 3, $green);

imageline($id_tick1, 70, 70, 275, 225, $red);

imagepng($id_tick1, $dest_file_img);

echo 
$dest_file_img; ?>
<br><br><img src="<?php echo $dest_file_img; ?>" 
alt="<?php echo $dest_file_img; ?>"><br>


 RESULT   

PNG 066 01 imagesetthickness-f.png

Resulting Image

PNG 066 01 imagesetthickness-f.png apr

  2 EXERCISE   

<?php

echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';

$base_img = "png/baseXx.png";

$dest_file_img = 'png/PNG 066 02 imagesetthickness-t.png';

$id_tick2 = imagecreatefrompng($base_img);
$yellow   = imagecolorallocate($id_tick2, 250, 255, 0);
$blue     = imagecolorallocate($id_tick2, 0, 0, 180);
$red      = imagecolorallocate($id_tick2, 180, 0, 0);
$green    = imagecolorallocate($id_tick2, 0, 180, 0);
$tick_triangle = 5;
$tick_rectangle = 10;

/* - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
   antialias => is set to TRUE
   - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */

$antialiastick2 = imageantialias($id_tick2, TRUE);

$tick_triangle = 
imagesetthickness($id_tick2, $tick_triangle);
imagerectangle($id_tick2, 50, 50, 300, 250, $blue);

$tick_rectangle = 
imagesetthickness($id_tick2, $tick_rectangle);

$vertices_array = array(100, 100, 150, 200, 250, 75); 
imagepolygon($id_tick2, $vertices_array, 3, $green);

imageline($id_tick2, 70, 70, 275, 225, $red);

imagepng($id_tick2, $dest_file_img);

echo 
$dest_file_img; ?>
<br><br><img src="<?php echo $dest_file_img; ?>" 
alt="<?php echo $dest_file_img; ?>"><br>


 RESULT   

PNG 066 02 imagesetthickness-t.png

Resulting Image

PNG 066 02 imagesetthickness-t.png apr


You should note the difference between the results of this exercise and the previous one.

In this, the imageantialias was considered as TRUE.
In the previous FALSE.