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...