Picture in PHP

zhaozj2021-02-12  157

That's right, PHP can also achieve the sharpening, blur, relief, etc. of the picture. Because PHP is not here as the web page foot, but in the case of efficiency, let us see what to do with CGI.

The following is already included in the FAQ of PHP in 9CBS: http://community.9cbs.net/expert/faq/faq_index.asp? Id = 188506

$ CNT = 0; for ($ x = 1; $ x <$ src_x; $ x ) for ($ y = 1; $ y ) {$ src_clr1 = imagecolorsforindex ($ src_im, imagecolorat ($ src_im) $ X-1, $ y-1)); $ SRC_CLR2 = ImageColorsforIndex ($ SRC_IM, IMAGECOLORAT ($ SRC_IM, $ X, $ Y); $ r = intVal ($ src_clr2 ["red"] $ degree * ($ SRC_CLR2 ["Red"] - $ src_clr1 ["red"])); $ g = intVal ($ src_clr2 ["green"] $ degree * ($ src_clr2 ["green"] - $ src_clr1 ["Green" ]); $ B = intV ($ src_clr2 ["blue"] $ degree * ($ src_clr2 ["blue"] - $ src_clr1 ["blue"]); $ r = min (255, max ($ R) , 0); $ g = min (255, max ($ g, 0)); $ b = min (255, max ($ b, 0)); // echo "R: $ R, G: $ G B: $ B "; IF ($ DST_CLR = ImageColorexact ($ DST_IM, $ R, $ G, $ B)) == - 1) $ dst_clr = ImageColor Allocate ($ DST_IM, $ R, $ G, $ B); $ CNT ; IF ($ DST_CLR == - 1) Die ("Color Allocate Faile AT $ x, $ y ($ cnt)."); imagesetpixel ($ dst_im, $ x, $ y, $ dst_clr);} return $ dst_im;} $ ImageFunctions = array ( "imagecreatefromwbmp", "imagecreatefromgif", "imagecreatefromjpeg", "imagecreatefrompng");! if (empty ($ _ POST [ "ImageName "])) {Set_time_limit (10 * 60);

IF ($ iMAGETYPE = GetImageType ($ _ post ["iMageName"]) == false) DIE ("Specify file does not exist or not a valid picture or does not support type!"); if ($ iMageType == 6) $ IMageType = 0; IF ($ iMAGETYPE> 3) Die ("Not supported picture type!"); $ IM1 = $ imagefunctions [$ imagetype] ($ _ post ["imagename"); $ IM2 = $ imagefunctions [$ iMAGETYPE ] ($ _ Pos "); // Print_R (ImageColorsfor Index ($ IM, ImageColoRAT)); Sharp ($ IM1, $ IM2, $ _POST [" degree "]); Header ("Content-Type: Image / PNG"); ImagePNG ($ IM2); ImageDestroy ($ IM1); ImageDestroy ($ IM2);}?>

Please enter the local path or URL of the image: "Size = 32> > ------------------------------------ --------------------------- Changed, save a $ IM: Function Sharp2 (& $ IM, $ DE Gree) {$ CNT = 0; for ($ x = imagesX ($ IMAGESX) -1; $ x> 0; $ x--) for ($ y = images) -1; $ y> 0; y - {$ CLR1 = ImageColorsforIndex ($ IM, ImageColorat ($ IM, $ X-1, $ Y-1)); $ CLR2 = ImageColorsfor Index ($ IM, ImageColorat ($ IM, $ X, $ Y)) ;

转载请注明原文地址:https://www.9cbs.com/read-6967.html

New Post(0)