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!