<? Php /* 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] ?> |