Add watermarks to php images, switch the profile picture and auto Scaling

Source: Internet
Author: User

You can add a watermark to an instance's php image, and switch the Avatar image and the auto scaling code. This allows you to generate a specified image size and automatically cut the image. See the example below.

You can add a watermark to an instance's php tutorial image, and cut the Avatar image and auto scaling code. This allows you to generate a specified image size and automatically cut the image, see the instance below.

<Html>
<Head>
<Meta http-equiv = "content-type" content = "text/html; charset = gb2312">
<Meta name = "author" content = "verdana core, phpdoc.net inc.">
<Title> file upload test </title>
</Head>
<Body>
<Form method = post enctype = "multipart/form-data" action = "<? Php echo url_for ("upload/webimages", true);?> ">
<Input type = "file" name = "upload" id = "upload" onchange = "preview ()";/>
<Br/>
<Input type = "submit" value = "Upload image">
</Form>
</Body>
</Html>

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

Img class in frameworklibimg. class. php

<?
/*
Add a watermark to a php image, and cut the Avatar image and auto-scaling code.

*/

Class uploadrouter extends controller {
Function index ()
{
// Output the upload form. For details, see View File.
}
Function webimages ()
{
Print_r ($ _ files );
$ Img = c ("img ");
$ Img-> setinfo (// sets the attributes of the uploaded file
Array ("files" => "upload", // name of the uploaded file box
"Uploadpath" => $ globals ['config'] ['webprojectpath']. "upimages/", // upload directory
"Icopath" => $ globals ['config'] ['webprojectpath']. "upimages/", // if not set, the upload directory is used.
"Icowidth" => "128", // thumbnail width
"Icoheight" => "98", // height of the thumbnail
"Fangpath" => $ globals ['config'] ['webprojectpath']. "upimages/_ ico/", // cut the square chart, that is, cut the Avatar, etc.
"Fangsize" => "75", // the size of the square chart. If a cut-side chart is set, a cut-side chart is generated during the upload. Do not leave it unspecified.
"Nzsize" => "180", // automatically set the width or height not to exceed this
"Uploadsize" => 420000 // size of the uploaded Image
)
)-> Setbasename ($ _ files ['upload'] ['name'], true)-> init (); //, 'size _ ico ', 'Auto _ ico ', 'fix _ ico', 'fill _ size', 'fix _ side'
// You can set the setbasename name by yourself. Otherwise, the date name will be automatically generated, and the Chinese name will be automatically replaced with Pinyin and filtered, And the init () will be initialized ()
// After initialization, you can upload the file.
If ($ img-> upload (array ('fix _ side') // uploaded, set whether to generate a thumbnail. If there are multiple formats that are left blank, only the uploaded images are ignored.
{
Echo ("uploaded successfully ");
} Else {
Echo ("Upload Failed ");
Echo $ img-> message;
}
Return false;
}
}


?>


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.