Based on the PHP implementation, such as compressed image size,
Don't say much nonsense, directly to everyone to paste PHP and other than the size of the compressed image of the relevant code, the specific code is as follows:
<?php$im = Imagecreatefromjpeg (' D:\phpplace\.jpeg '); Resizeimage ($im,,, ' xinde ', '. jpg '); function Resizeimage ($im , $maxwidth, $maxheight, $name, $filetype) {$pic _width = Imagesx ($im); $pic _height = Imagesy ($im); echo " Start-----------------"if ($maxwidth && $pic _width > $maxwidth) && ($maxheight && $pic _ Height > $maxheight) {if ($maxwidth && $pic _width> $maxwidth) {$widthratio = $maxwidth/$pic _width;$ Resizewidth_tag = true;} if ($maxheight && $pic _height> $maxheight) {$heightratio = $maxheight/$pic _height; $resizeheight _tag = true;} if ($resizewidth _tag && $resizeheight _tag) {if ($widthratio < $heightratio) $ratio = $widthratio; else$ratio = $ HeightRatio;} if ($resizewidth _tag &&! $resizeheight _tag) $ratio = $widthratio; if ($resizeheight _tag &&! $resizewidth _tag) $ratio = $heightratio; $newwidth = $pic _width * $ratio; $newheight = $pic _height * $ratio; if (Function_exists (" Imagecopyresampled ") {$newim = Imagecreatetruecolor ($newwidth, $neWheight) imagecopyresampled ($newim, $im,,,,, $newwidth, $newheight, $pic _width, $pic _height);} else{$newim = imagecreate ($newwidth, $newheight); imagecopyresized ($newim, $im,,,,, $newwidth, $newheight, $pic _width, $pic _height);} $name = $name. $filetype; imagejpeg ($newim, $name); Imagedestroy ($newim);} else{$name = $name. $filetype; imagejpeg ($im, $name);}}
The above code content is small to introduce to you based on the PHP implementation and other than the size of the compressed image of the relevant content, the code is easy to understand, where the bad writing, welcome to all the heroes to put forward valuable comments, small series is very happy.
Articles you may be interested in:
- PHP thumbnail, such as proportional lossless compression, can fill the blank area supplemental color
- PHP uses the Imagick module for image scaling, cropping, and compression examples
- PHP implementation of bulk compressed picture file size Script
- Two examples of image compression implemented by PHP
- PHP to add watermark to the image compression cut package class
- PHP image watermark Add, compress, cut package class implementation
- PHP implementation image upload and compression
- How to implement PHP upload image and compress
http://www.bkjia.com/PHPjc/1106112.html www.bkjia.com true http://www.bkjia.com/PHPjc/1106112.html techarticle based on the PHP implementation and other than the compressed image size, no nonsense to say, directly to everyone to paste PHP and other than the compressed image size of the relevant code, the specific code is as follows: Php$im = Imagecreatefr ...