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

1690 - ImageMagick 6.9.10-6
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 18 Color's opacity
imagick::COLOR_ALPHA19 Color's alpha
imagick::COLOR_FUZZ20 Color's fuzz
ed48

  1 EXERCISE   

<?php

// Run several times

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

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

$width mt_rand(0100);

$height mt_rand(0100);

$op mt_rand(12);

if(
$op == 1)
{
$r mt_rand(015);
$g mt_rand(015);
$b mt_rand(015);


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(16255);
$g mt_rand(16255);
$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(19, 233, 92)

Color = #13e95c
Width = 73
Height = 4

borderImage(#13e95c, 73, 4);


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(0100);

$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 = 69
Height = 69

borderImage(Red, 69, 69);


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(0100);

$imagick = new Imagick($path);

$r mt_rand(0255);
$g mt_rand(0255);
$b mt_rand(0255);

$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(28, 46, 157)
Width = 54
Height = 54

borderImage(rgb(28, 46, 157), 54, 54);


1529859269.jpg

img/xtr/blu/1529859269.jpg apr

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