Home > Backend Development > PHP Tutorial > PHP adds text watermark and image watermark code to pictures (1/3)_PHP tutorial

PHP adds text watermark and image watermark code to pictures (1/3)_PHP tutorial

WBOY
Release: 2016-07-13 10:45:09
Original
1086 people have browsed it

Add text watermark and image watermark code to pictures with php When this program adds text watermarks to pictures, it calls the C:\WINDOWS\Fonts\SIMHEI.TTF font. When adding watermarks to pictures, you can customize the pictures.

php tutorial to add text watermark and image watermark code to pictures
When this program adds text watermarks to pictures, it calls the c:windowsfontssimhei.ttf font. When adding watermarks to pictures, you can customize the pictures.
$image->wprint_img();//Execute image watermark
$image->wprint_string();//Execute text watermark
*/

class editimage{
private $imagefile; //Image file
private $smallimg;//Watermark image
private $string;//watermark text
private $position;//storage location
private $dst_x=600;//Original image watermark x coordinate
private $dst_y=0; //Original picture watermarked y coordinate
private $str_x=450;
private $str_y=200;
private $font="c:windowsfontssimhei.ttf";//Original picture watermark font path
private $imgej;//Variables after imagecolorallocate

function __get($value){
Return $this->$value;
}
function __set($property,$value){
$this->$property=$value;
}
/**
*Constructor initialization
*
* @param string $imagefile The watermarked file
* @param string $smallimg watermark file
* @param string $string watermark text
* @param string $position storage location
* @param int $dst_x The watermarked picture x
* @param int $dst_y The watermarked picture y
​*/
function __construct($imagefile,$smallimg='',$string=''){//,$position='',$dst_x=0,$dst_y=0
$this->imagefile=$imagefile;
$this->smallimg=$smallimg;
$this->string=$string;
$this->imgej=$this->imagecreatef($this->imagefile);
}

function get_extname($file){//Get the suffix name of the file
if (file_exists($this->imagefile)) {
$img=getimagesize($file);
switch ($img[2]){
case "1":
Return "gif";
case "2":
Return "jpg";
case "3":
Return "png";
}
}else{
Return false;
}
}

1 2 3

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633042.htmlTechArticlephp adds text watermark to pictures and picture watermark code. When this program adds text watermark to pictures, it calls C: \WINDOWS\Fonts\SIMHEI.TTF font, you can customize the picture when adding watermark to the picture...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template