Imagick::borderImage


wizard apg

ADDS a boder to an image.



<?php

bool 
public Imagick::borderImage(
                                     
mixed $bordercolor,
                                         
int $width, 
                                         
int $height)
                                             );

?>

$bodercolor


ImagickPixel object or a string containing the border color.



$width


The width of border.



$height


The height of border





This function returns true on success.



AVAILABLE "imagick" COLORS
STUDIED IN THIS TUTORIAL

1810 - ImageMagick 7.1.2-34
COLOR
CONSTANTVALABOUT
imagick::COLOR_BLACK11 Black color
imagick::COLOR_BLUE12 Blue color
imagick::COLOR_CYAN13 Cyan color
imagick::COLOR_GREEN14 Green color
imagick::COLOR_RED15 Red color
imagick::COLOR_YELLOW16 Yellow color
imagick::COLOR_MAGENTA17 Magenta color
imagick::COLOR_OPACITY Color's opacity
imagick::COLOR_ALPHA18 Color's alpha
imagick::COLOR_FUZZ19 Color's fuzz
ed48

  1 EXERCISE   

<?php

// Run several times

$path = PATH2IMGW . '/xtr/1529860572.jpg';

$str1img = 'img/xtr/blu/1529860572b.jpg';

$width = mt_rand(0, 100);

$height = mt_rand(0, 100);

$op = mt_rand(1, 2);

if(
$op == 1)
{
$r = mt_rand(0, 15);
$g = mt_rand(0, 15);
$b = mt_rand(0, 15);


echo 
"RGB($r, $g, $b)<br><br>";

$rr = dechex($r);
$gg = dechex($g);
$bb = dechex($b);

$color = '#'. '0'."$rr". '0' . "$gg" . '0' . "$bb";

}
elseif(
$op == 2)
{
$r = mt_rand(16, 255);
$g = mt_rand(16, 255);
$b = mt_rand(16,255);


echo 
"RGB($r, $g, $b)<br><br>";

$rr = dechex($r);
$gg = dechex($g);
$bb = dechex($b);

$color = '#'. "$rr$gg$bb";
    
}

$imagick = new Imagick($path);

$imagick->borderImage($color, $width, $height);

$imagick = $imagick->getImageBlob();

$img = imagecreatefromstring($imagick);

imagegif($img, $str1img);

echo 
basename($str1img); ?>
<br><br>
<img src="<?php echo $str1img; ?>"
 alt="<?php echo $str1img; ?>" 
 title="<?php echo $str1img; ?>">

 RESULT   

RGB(14, 1, 10)

Color = #0e010a
Width = 52
Height = 5

borderImage(#0e010a, 52, 5);


1529860572b.jpg

img/xtr/blu/1529860572b.jpg apr

Moods Bistro & Coffee, Bratislava Bratislava (SVK) - 2018.

  2 EXERCISE   

<?php

// Run several times

$path = PATH2IMGW . '/xtr/1529784556.jpg';

$str2img = 'img/xtr/blu/1529784556b.jpg';

$width = $height = mt_rand(0, 100);

$color = 'Red';

$imagick = new Imagick($path);

echo 
"Color = $color<br>Width = $width<br>Height = $height<br><br>";

echo 
"borderImage($color, $width, $height);<br><br>";

$imagick->borderImage($color, $width, $height);

$imagick = $imagick->getImageBlob();

$img = imagecreatefromstring($imagick);

imagegif($img, $str2img);

echo  
basename($str2img); ?>
<br><br>
<img src="<?php echo $str2img; ?>"
 alt="<?php echo $str2img; ?>" 
 title="<?php echo $str2img; ?>">

Color = Red
Width = 39
Height = 39

borderImage(Red, 39, 39);


1529784556b.jpg

img/xtr/blu/1529784556b.jpg apr

Sanctuary of Fatima - (POR) - 2018.

  3 EXERCISE   

<?php

// Run several times

$path = PATH2IMGW . '/xtr/1529859269.jpg';

$str3img = 'img/xtr/blu/1529859269.jpg';

$width = $height = mt_rand(0, 100);

$imagick = new Imagick($path);

$r = mt_rand(0, 255);
$g = mt_rand(0, 255);
$b = mt_rand(0, 255);

$color = 'rgb(' . "$r, $g, $b" . ')';

echo 
"Color = $color<br>Width = $width<br>Height = $height<br><br>";

echo 
"borderImage($color, $width, $height);<br><br>";

$imagick->borderImage($color, $width, $height);

$imagick = $imagick->getImageBlob();

$img = imagecreatefromstring($imagick);

imagegif($img, $str3img);

echo  
basename($str3img); ?>
<br><br>
<img src="<?php echo $str3img; ?>"
 alt="<?php echo $str3img; ?>" 
 title="<?php echo $str3img; ?>">

Color = rgb(38, 52, 159)
Width = 65
Height = 65

borderImage(rgb(38, 52, 159), 65, 65);


1529859269.jpg

img/xtr/blu/1529859269.jpg apr

Dunakapu Square is in the northern part of downtown Győr (HUN) - 2018.