For details about how to zoom in and out a piece of code, see

Source: Internet
Author: User
Function resize ($ srcImage, $ toFile, $ maxWidth = 450, $ maxHeight = 450, $ imgQuality = 100)
{

List ($ width, $ height, $ type, $ attr) = getimagesize ($ srcImage );
If ($ width <$ maxWidth | $ height <$ maxHeight) return;
Switch ($ type ){
Case 1: $ img = imagecreatefromgif ($ srcImage); break;
Case 2: $ img = imagecreatefromjpeg ($ srcImage); break;
Case 3: $ img = imagecreatefrompng ($ srcImage); break;
}
$ Scale = min ($ maxWidth/$ width, $ maxHeight/$ height); // calculates the bloom ratio.

If ($ scale <1 ){
$ NewWidth = floor ($ scale * $ width );
$ NewHeight = floor ($ scale * $ height );
$ NewImg = imagecreatetruecolor ($ newWidth, $ newHeight );
Imagecopyresampled ($ newImg, $ img, 0, 0, 0, 0, $ newWidth, $ newHeight, $ width, $ height );
$ NewName = "";
$ ToFile = preg_replace ("/(.gif |. jpg |. jpeg |. png)/I", "", $ toFile );

Switch ($ type ){
Case 1: if (imagegif ($ newImg, "too tofile=newname.gif", $ imgQuality ))
Return "invalid newname.gif"; break;
Case 2: if (imagejpeg ($ newImg, "$tofile=newname.jpg", $ imgQuality ))
Return "maid"; break;
Case 3: if (imagepng ($ newImg, "$tofile=newname.png", $ imgQuality ))
Return "maid"; break;
Default: if (imagejpeg ($ newImg, "$tofile=newname.jpg", $ imgQuality ))
Return "maid"; break;
}
Imagedestroy ($ newImg );
}
Imagedestroy ($ img );
Return false;
}


I found this on the Internet, but it can be scaled down normally, but how can it be zoomed in,

Please try again


Reply to discussion (solution)

You can remove the if ($ scale <1) {condition to enlarge it.

You can remove the if ($ scale <1) {condition to enlarge it.



I will go .. My eyes .. Thank you!

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.