PHP dynamic effect of adding a transparency gradient to the image _ PHP Tutorial

Source: Internet
Author: User
PHP dynamically adds the transparency gradient effect to the image. Today, due to temporary needs, we need to dynamically add the transparency gradient effect to the image. I found an algorithm that does not have the corresponding function for a long time on the internet .... I wrote one myself: The following is the reference content. due to temporary needs today, we need to dynamically add the transparency gradient effect to the image, I found an algorithm that does not have the relevant functions for a long time on the internet ....

I wrote one myself:

Reference content is as follows:

/// $ Strimgsrc = file_get_contents ("http: // 127.0.0.1/5307754.jpg ");
//// $ Imgsrc = imagecreatefromstring ($ strimgsrc );
$ Imgsrc = imagecreatefromjpeg ("5307754.jpg ");
$ Imgsrcw = imagesx ($ imgsrc );
$ Imgsrch = imagesy ($ imgsrc );

$ Width = 30;
$ X1 = 2;
$ X2 = $ imgsrcw-$ x1-20;
$ Y1 = ($ imgsrch-$ width)-2;
$ Y2 = $ y1 + $ width;

$ Steps = $ x2-$ x1;
For ($ I = 0; $ I <$ steps; $ I ++)
{
$ Alphax = round ($ I/($ steps/127) + 60;
If ($ alphax> = 128)
$ Alphax = 127;
$ Alpha = imagecolorallocatealpha ($ imgsrc, 255,255,255, $ alphax );
Imagefilledrectangle ($ imgsrc, ($ I + $ x1), $ y1, ($ I + $ x1 + 1), $ y2, $ alpha );
}

Header (content-type: image/jpeg );

Imagejpeg ($ imgsrc );
Imagedestroy ($ imgsrc );
?>

I wrote one myself: the reference content is as follows...

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.