Php watermarks images. 3. PHP source code

Source: Internet
Author: User
Ec (2); & lt ;? FunctionsetMaskTxtPct ($ n) & nbsp; {& nbsp; $ this-& gt; mask_txt_pct (int) $ n; & nbsp ;}& nbsp; & nbsp; ** & nbsp; & script ec (2); script

Function setMaskTxtPct ($ n)
{
$ This-> mask_txt_pct = (int) $ n;
}

/**
* Set the thumbnail border
*
* @ Param (type) (parameter name) (description)
*/
Function setDstImgBorder ($ size = 1, $ color = "#000000 ")
{
$ This-> img_border_size = (int) $ size;
$ This-> img_border_color = $ color;
}

/**
* Horizontal flip
*/
Function flipH ()
{
$ This-> _ flip_x ++;
}

/**
* Vertical flip
*/
Function flipV ()
{
$ This-> _ flip_y ++;
}

/**
* Set the cut type.
*
* @ Param (type) (parameter name) (description)
*/
Function setCutType ($ type)
{
$ This-> cut_type = (int) $ type;
}

/**
* Set image cropping.
*
* @ Param integer $ width rectangular cut
*/
Function setRectangleCut ($ width, $ height)
{
$ This-> fill_w = (int) $ width;
$ This-> fill_h = (int) $ height;
}

/**
* Set the starting coordinate point of the source image cut.
*
* @ Param (type) (parameter name) (description)
*/
Function setSrcCutPosition ($ x, $ y)
{
$ This-> src_x = (int) $ x;
$ This-> src_y = (int) $ y;
}

/**
* Create an image. Main Function
* @ Param integer $ a when the second parameter is missing, this parameter is used as a percentage,
* Otherwise, it is used as the width value.
* @ Param integer $ B the scaled height of the image
*/
Function createImg ($ a, $ B = null)
{
$ Num = func_num_args ();
If (1 = $ num)
{
$ R = (int) $;
If ($ r <1)
{
Die ("image scaling ratio cannot be less than 1 ");
}
$ This-> img_scale = $ r;
$ This-> _ setNewImgSize ($ r );
}

If (2 = $ num)
{
$ W = (int) $;
$ H = (int) $ B;
If (0 = $ w)
{
Die ("the target width cannot be 0 ");
}
If (0 = $ h)
{
Die ("the Target Height cannot be 0 ");
}
$ This-> _ setNewImgSize ($ w, $ h );
}

If ($ this-> _ flip_x % 2! = 0)
{
$ This-> _ flipH ($ this-> h_src );
}

If ($ this-> _ flip_y % 2! = 0)
{
$ This-> _ flipV ($ this-> h_src );
}
$ This-> _ createMask ();
$ This-> _ output ();

// Release
If (imagedestroy ($ this-> h_src) & imagedestroy ($ this-> h_dst ))
{
Return true;
}
Else
{
Return false;
}
}

?>

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.