Use php to zoom in and out images)
Php enables simple image scaling.
- /**
- * The Images class is an image processing class.
- * @ Author pan
- * @ Package application. controllers
- * @ Since 1.0
- */
- Class Images
- {
- /**
- * Scale an image
- * @ Param $ source original image
- * @ Param $ newfile New Image
- * @ Param $ pre zoom ratio
- */
- Public function thumn ($ source, $ pre, $ newfile)
- {
- // Obtain the image size
- List ($ s_w, $ s_h) = getimagesize ($ source );
- // Generate a new image size
- $ New_w = $ s_w * $ pre;
- $ New_h = $ s_h * $ pre;
- // Create a new image
- $ New_f = imagecreatetruecolor ($ new_w, $ new_h );
- // Create an image with a resource image
- $ Sour_f = imagecreatefromjpeg ($ source );
- // Copy the resource image to the new image
- Imagecopyresampled ($ new_f, $ sour_f, 0, 0, 0, 0, $ new_w, $ new_h, $ s_w, $ s_h );
- // Output the image to the browser
- Imagejpeg ($ new_f, $ newfile );
- Imagedestroy ($ new_f );
- Imagedestroy ($ sour_f );
- }
- }
- ?>
|