PHP picture watermark, cut avatar and auto zoom _php Tutorial

Source: Internet
Author: User
An example of PHP image watermark, cut head image and automatic scaling code, he can upload your uploaded images to generate a specified size and can be automatically cut the picture, see the example below.

An example of PHP tutorial picture watermark, cut head image and auto-scaling code, he can upload your uploaded images to generate a specified size with the picture can be automatically cut, see the example below.





Upload file test




Http://code.google.com/p/queryphp/downloads/list

IMG Classes in the frameworklibimg.class.php

/*
PHP image watermark, cut head image and auto-scaling code

*/

Class Uploadrouter extends controller{
Function index ()
{
Output upload form, see View File
}
function Webimages ()
{
Print_r ($_files);
$img =c ("img");
$img->setinfo (//Set upload file properties
Array ("Files" = "upload",//Upload file Box name name
"Uploadpath" = $globals [' config '] [' Webprojectpath ']. " Upimages/",//Upload Directory
"Icopath" = $globals [' config '] [' Webprojectpath ']. " Upimages/",//Small map directory if not set will be used to upload directory
"Icowidth" = "128",//Small picture width
"Icoheight" = "98",//Tugau
"Fangpath" = $globals [' config '] [' Webprojectpath ']. " upimages/_ico/",//Cefanto, is cut head, etc.
"Fangsize" = "75",//Fanthou How big if the Cefanto is set up then upload will generate Cefanto, do not have to set
"Nzsize" = "180",//automatic setting wide or high does not exceed this
"Uploadsize" =>420000//Upload image size
)
)->setbasename ($_files[' upload ' [' name '],true)->init ();//, ' Size_ico ', ' Auto_ico ', ' Fix_ico ', ' fill_size ' Fix_side '
You can set the Setbasename name yourself, or the date name will be automatically generated, which will automatically change the Chinese into Pinyin and filter the last initialization of Init ()
After initialization, you can upload the
if ($img->upload (' fix_side '))//uploaded, set to not generate a small graph. There are many formats if it is empty then only upload pictures other ignore.
{
Echo ("Upload success");
}else{
Echo ("Upload failed");
Echo $img->message;
}
return false;
}
}


?>


http://www.bkjia.com/PHPjc/444842.html www.bkjia.com true http://www.bkjia.com/PHPjc/444842.html techarticle An example of PHP image watermark, cut head image and automatic scaling code, he can upload your uploaded images to generate a specified size with the image can be automatically cut, see the example below ...

  • 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.