Php code for adding a text watermark and an image watermark to an image (1/2)

Source: Internet
Author: User
Tags php code

$ Image-> wprint_img (); // executes the image watermark.
$ Image-> wprint_string (); // execute a text watermark
*/

The code is as follows: Copy code

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: windows ontssimhei. 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;
  }
 }  
 

 

Homepage 1 2 Last page

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.