Thumbnail generated PHP program [from Osso]

Source: Internet
Author: User
Tags exit empty
Program | Thumbnail client uploaded page:
--------------------upload.htm---------------------
<form enctype= "Multipart/form-data"
Method= "POST" action= "upload.php" >
<input type= "hidden" name= "max_file_size" value= "10240000000" > Please select or enter the upload file name: <input name= "upfile" type= "file" >
<input type= "Submit" value= "Start uploading" >



---------------------upload.php-------------------
?
if (empty ($upfile)) {
Print ("No file was transfered!\n no files uploaded!");
Exit
}
$image _path= $upfile;
@ $image _info=getimagesize ($image _path);
if ($image _info[2]==2)
{@ $image 2=imagecreatefromjpeg ($image _path);
}
else if ($image _info[2]==1) {
@ $image 2=imagecreatefromgif ($image _path);
}
Else{print ("Don't accept the picture!") "); exit;}
if (Empty ($image 2)) {print ("system error, please retry"); exit;}
$image 2_x=imagesx ($image 2);
$image 2_y=imagesy ($image 2);
if ($image 2_x== $image 2_y) {
$x = 150;
$y = 0;
}
else if ($image 2_x> $image 2_y) {
$x = 150;
$y =intval (150* $image 2_y/$image 2_x);
}
else{
$y = 150;
$x =intval (150* $image 2_x/$image 2_y);
}
$image 1=imagecreate ($x, $y);

Imagecopyresized ($image 1, $image 2,0,0,0,0, $x, $y, $image 2_x, $image 2_y);
Imagegif ($image 1, "new.gif");
?>

-------------------------Description----------------------
This code is characterized by the conversion of all unsightly warning to an error prompt that can be exported from the design, @ The effect is to suppress lending information. This code by default converts a picture to a thumbnail that is no longer than 150 pixels long and is saved as a new.gif. Can be modified at will when used.
This code is produced by Turtlevan (turtlevan@263.net), you can arbitrarily use and modify, can also be spread on the network, but not plagiarism for already.

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.