Create an obsessive-compulsive avatar using thinkphp + jcrop
1. [image] qb.png
2. [PHP] code
// Key code // Copy the avatar to the new canvas $ newhead = imageCreatetruecolor (180,180); // Create a whiteboard and imagesavealpha ($ newhead, true ); $ color = imagecolorallocatealpha ($ newhead, 255,255,255,127); imagecolortransparent ($ newhead, $ color); imagefill ($ newhead, 0, 0, $ color); imagecopyresampled ($ newhead, $ image, imagesx ($ image), imagesy ($ image), imagesx ($ image), imagesy ($ image )); // create a new canvas and copy the numeric background $ num_bg = ". /Public/Images/icon-head2.png "; $ num_bg_src = values ($ num_bg); $ num_bg_new = values (imagesx ($ num_bg_src), imagesy ($ num_bg_src); imagesavealpha ($ num_bg_new, true); // create a white background for the true color canvas and set it to transparent $ color = imagecolorallocatealpha ($ num_bg_new, 255,255,255,127); imagecolortransparent ($ num_bg_new, $ color ); imagefill ($ num_bg_new, 0, 0, $ color); imagecopyresampled ($ num_bg_new, $ num_bg_src, imagesx ($ num_bg_new), imagesy ($ num_bg_new ), imagesx ($ num_bg_new), imagesy ($ num_bg_new ));