GD image processing under the TP _ framework (including basic php image processing ideas)
Info = array ('width' => $ info [0], 'height' => $ info [1], 'type' => image_type_to_extension ($ info [2], false), 'Mime '=> $ info ['Mime']); $ fun = "imagecreatefrom {$ this-> info ['type']}"; $ this-> image = $ fun ($ src);} public function getImage () {return $ this-> image;} public function getInfo () {return $ this-> info;}/*** image compression * @ param $ width * @ param $ height */public function thumb ($ width, $ height) {$ image_thumb = image Createtruecolor ($ width, $ height); imagecopyresampled ($ image_thumb, $ this-> image, 0, 0, 0, $ width, $ height, $ this-> info ['width'], $ this-> info ['height']); imagedestroy ($ this-> image ); $ this-> image = $ image_thumb;}/*** font watermark (lower left corner by default) * @ param $ fontfile font file consolaz. ttf * @ param $ text watermark content */public function fontMark ($ fontfile, $ text) {// red, green, and blue = White + 50 transparency font $ col = imagecolorallocatealpha ($ this-> image, 255,255,255, 50); // Image font synthesis-parameter: image, font size, deflection angle, horizontal offset, vertical offset, color, font file, content imagettftext ($ this-> image, 50, 0, 40, $ this-> info ['height']-50, $ col, $ fontfile, $ text );} /*** image watermark ** @ param $ water watermark image * @ param $ waterInfo watermark image information */public function imageMark ($ water, $ waterInfo) {imagecopymerge ($ this-> image, $ water, $ waterInfo ['width'], $ waterInfo ['height'], 20 ); /* image merging-parameter: target image, watermark image, horizontal offset, vertical offset, * copy at watermark image x, copy at watermark image y, * Watermark Image x End copying, end copying at watermark image y, and transparency of watermark image. */Imagedestroy ($ water);} public function showInHtml () {header ("content-type :". $ this-> info ['Mime ']); $ funs = "image {$ this-> info ['type']}"; $ funs ($ this-> image);}/*** save image * @ param $ newName save file name */public function saveImage ($ newName) {$ funs = "image {$ this-> info ['type']}"; $ funs ($ this-> image, "$ newName. ". $ this-> info ['type']); // save the image} public function _ destruct () {imagedestroy ($ this-> image );}}