PHP image watermarking, cut the head like a picture and automatically zoom

Source: Internet
Author: User
Keywords Network programming PHP tutorial
Tags .mall class code content directory echo example file

An example of PHP tutorial image watermarking, cut the head like a picture and automatically zoom code, he can upload your pictures to generate the specified size renderings and pictures can be automatically cut, see the following example.

<html>
<head>
<meta http-equiv = "content-type" content = "text / html; charset = gb2312">
<meta name = "author" content = "verdana core, phpdoc.net inc.">
<title> Upload File 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 /> <br />
<input type = "submit" value = "Upload Image">
</ form>
</ body>
</ html>

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

img class in frameworklibimg.class.php

<?
/ *
PHP image watermarking, cut the head like a map and automatically zoom code

* /

class uploadrouter extends controller {
function index ()
{
// Output upload form, see the view file
}
function webimages ()
{
print_r ($ _ files);
$ img = c ("img");
$ img-> setinfo (/ / Set upload file attributes
array ("files" => "upload", // upload file name
"uploadpath" => $ globals ['config'] ['webprojectpath']. "upimages /", // upload directory
"icopath" => $ globals ['config'] ['webprojectpath']. "upimages /", // thumbnail directory if not set will use the upload directory
"icowidth" => "128", // small picture width
"icoheight" => "98", // small picture high
"fangpath" => $ globals ['config'] ['webprojectpath']. "upimages / _ico /"
"fangsize" => "75", // plots how big If you set the cut square diagram then upload will generate a cut square, do not do not set
"nzsize" => "180", // automatically set this width or height
"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 name of the setbasename will automatically generate the name of the date, which will automatically swap the Chinese into Pinyin and filter the final initialization init ()
// Initialization is completed, you can upload
if ($ img-> upload (array ('fix_side'))) / / upload, set to generate a small map. There are many formats if it is empty then upload pictures only ignore the other.
{
echo ("upload success");
} else {
echo ("upload failed");
echo $ img-> message;
}
return false;
}
}


?>

Related Article

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.