Php adds Gray and transparent effects to images. This article will introduce you to an article about the gray and transparent effects of php on images. I hope this method will be helpful to you. Principle: 1. calculate the size of the original image. create an article to introduce the gray and transparent effects of php on images. I hope this method will be helpful to you.
Principle:
1. calculate the size of the original image
2. create a translucent image of the same size
3. use the imagecopy () method to merge the newly created translucent image with the original image.
The code is as follows: |
|
/* Add Gray and transparent effects to images in php */ $ Imfile = './0.jpg'; // source image $ Origim = imagecreatefromjpeg ($ imfile); // create an image from a JPEG file or URL $ W = imagesx ($ origim); // source image width $ H = imagesy ($ origim); // The height of the source image $ Newimg = imagecreatetruecolor ($ w, $ h); // returns an image identifier, representing a black image of x_size and y_size. Imagecreatetruecolor // $ Color = imagecolorallocatealpha ($ newimg,); // assign color + alpha to an image; same as imagecolorallocate (), but with an additional transparency parameter alpha, the value ranges from 0 to 127. 0 indicates full opacity, and 127 indicates full transparency. Imagecolortransparent ($ newimg, $ color); // define a color as transparent Imagefill ($ newimg, 0, 0, $ color); // fill in the area; resource $ image, int $ x, int $ y, int $ color Imagecopy ($ origim, $ newimg, 0, 0, $ w, $ h); // Copy part of the image. start the coordinates of the src_im image from src_x, src_y, part of the width src_w and height src_h is copied to the position where the coordinates of dst_im are dst_x and dst_y. Imagejpeg ($ origim, './2.jpg'); // output the image to a browser or file .; Resource $ image [, string $ filename [, int $ quality] ?> |
I hope this method will be helpful to you. Principle: 1. calculate the size of the original image 2. create a phase...