Php code for adding a text watermark and an image watermark to an image (1/3) _ PHP Tutorial

Source: Internet
Author: User
Php adds a text watermark and image watermark code to an image (13 ). Php adds text watermark and image watermark code to the image. this program calls C: \ WINDOWS \ Fonts \ SIMHEI when adding text watermark to the image. TTF font, you can customize the image when adding a watermark to the image. php adds a text watermark and image watermark code to the image. this program calls C when adding a text watermark to the image: \ WINDOWS \ Fonts \ SIMHEI. TTF font. you can customize the image when adding a watermark to the image.

Php Tutorial: add a text watermark and image watermark code to an image
This program calls the c: windowsfontssimhei. ttf font when adding text watermark to the image. you can customize the image when adding a watermark to the image.
$ Image-> wprint_img (); // executes the image watermark.
$ Image-> wprint_string (); // execute a text watermark
*/

Class editimage {
Private $ imagefile; // image file
Private $ smallimg; // watermark image
Private $ string; // watermark text
Private $ position; // storage location
Private $ dst_x = 600; // the x coordinate of the original image watermark
Private $ dst_y = 0; // the y coordinate of the original image watermark.
Private $ str_x = 450;
Private $ str_y = 200;
Private $ font = "c: windowsfontssimhei. ttf"; // watermark the font path of the original image
Private $ imgej; // The variable after imagecolorallocate

Function _ get ($ value ){
Return $ this-> $ value;
}
Function _ set ($ property, $ value ){
$ This-> $ property = $ value;
}
/**
* Constructor initialization
*
* @ Param string $ imagefile the watermark file
* @ Param string $ smallimg watermark file
* @ Param string $ string watermark text
* @ Param string $ position storage location
* @ Param int $ dst_x watermark image x
* @ Param int $ dst_y the watermark image 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 file suffix
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

Upload the C: \ WINDOWS \ Fonts \ SIMHEI. TTF font. you can customize the image when adding a watermark to the image...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.