The two php images are scaled proportionally. The php image proportional scaling code is a user-uploaded image to specify the proportional size of the image. The principle is to calculate the proportional size of the image, the second step is to generate a thumbnail, php image, and other proportional scaling code. the code is an image with a specified proportional size based on the image uploaded by the user. The principle is simply to calculate the proportional ratio of the image size, the second step is to generate a small image with a fixed image size. However, it is a good way to set the image size to a value smaller than the set image size.
Php Tutorial Image proportional scaling code is a user-uploaded image to specify the proportion of the image, the principle is very simple is to calculate the size of the image into the proportion of the line, the second step is to generate a small image with a fixed image size. However, it is a good way to set the image size to a value smaller than the set image size.
Header ("content-type: image/jpeg ");
$ Filename = hsdir. '/mljntc2p.jpg ';
$ Im = imagecreatefromjpeg ($ filename );
$ H = imagesy ($ im); // Obtain the target image height
$ New_img_width = 257;
$ New_img_height = 522;
$ Newim = imagecreate ($ new_img_width, $ new_img_height );
$ White = imagecolorallocate ($ newim, 255,255,255); // set the background color.
Imagecopyresized ($ newim, $ im, 0, 0, 0, 0, $ new_img_width, $ new_img_height, $ new_img_width, $ new_img_height );
Imagefilledrectangle ($ newim, 0, $ h, $ new_img_width, $ new_img_height, $ white );
// Fill in the target image height as the starting y coordinate to specify the intercepting width and height as the ending coordinate
Imagejpeg ($ newim );
Imagedestroy ($ newim );
Imagedestroy ($ im );
?>
Code 2
Header ("content-type: image/jpeg ");
$ Filename = 'myface.jpg ';
$ Im = imagecreatefromjpeg ($ filename );
$ New_img_width = 80;
$ New_img_height = 150;
$ Newim = imagecreate ($ new_img_width, $ new_img_height );
$ White = imagecolorallocate ($ newim, 255,255,255); // set the background color.
Imagecopyresized ($ newim, $ im, 0, 0, 0, 0, $ new_img_width, $ new_img_height, $ new_img_width, $ new_img_height );
Imagejpeg ($ newim );
Imagedestroy ($ newim );
Imagedestroy ($ im );
?>
Http://www.bkjia.com/PHPjc/633018.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/633018.htmlTechArticlephp Image proportional scaling code is based on the user to upload images to specify the proportion of the size of the image, the principle is very simple is to calculate the size of the image into the proportion of the line, the second paragraph to generate a small image...