note 41550 added to function.imageline
| From: | yl at sota dot ch | Date: | Wed, 14 Apr 2004 13:44:41 +0000 |
| Subject: | note 41550 added to function.imageline | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68110@lists.php.net to get a copy of this message | ||
Simple function to create border for jpg-images:
function createImageBorder($imgName){
$img = substr($imgName, 0, -4); // remove fileExtension
$ext = ".jpg";
$quality = 95;
$borderColor = 255; // 255 = white
/*
a b
+-------------------------+
|
| IMAGE
|
+-------------------------+
c d
*/
$scr_img = imagecreatefromjpeg($img.$ext);
$width = imagesx($scr_img);
$height = imagesy($scr_img);
// line a - b
$abX = 0;
$abY = 0;
$abX1 = $width;
$abY1 = 0;
// line a - c
$acX = 0;
$acY = 0;
$acX1 = 0;
$acY1 = $height;
// line b - d
$bdX = $width-1;
$bdY = 0;
$bdX1 = $width-1;
$bdY1 = $height;
// line c - d
$cdX = 0;
$cdY = $height-1;
$cdX1 = $width;
$cdY1 = $height-1;
// DRAW LINES
imageline($scr_img,$abX,$abY,$abX1,$abY1,$borderColor);
imageline($scr_img,$acX,$acY,$acX1,$acY1,$borderColor);
imageline($scr_img,$bdX,$bdY,$bdX1,$bdY1,$borderColor);
imageline($scr_img,$cdX,$cdY,$cdX1,$cdY1,$borderColor);
// create copy from image
imagejpeg($scr_img, $img."_border.jpg", $quality);
imagedestroy($scr_img);
}
createImageBorder("myfile.jpg");
----
Manual Page -- http://www.php.net/manual/en/function.imageline.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41550
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41550&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41550&report=yes
Search -- http://master.php.net/manage/user-notes.php