GD image processing under the TP _ framework (including basic php image processing ideas)-php Tutorial

Source: Internet
Author: User
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 );}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.