Home > Backend Development > PHP Tutorial > PHP image reduction function_PHP tutorial

PHP image reduction function_PHP tutorial

WBOY
Release: 2016-07-13 17:48:15
Original
935 people have browsed it

删除了原始图片保留了操作后的图片

  /**
* Reduce image function
* @param string $fileName
* @return void
​*/
private function createSmallImg($fileName)
{
    list($width,$height,$type,$attr) = getimagesize($fileName);
    $imgOld=imagecreatefromjpeg($fileName);
    $imgObj=imagecreatetruecolor($width-100,$height-100);
    if(function_exists('imagecopyresampled'))
    {
    imagecopyresampled($imgObj,$imgOld,0,0,0,0,$width-100,$height-100,imagesx($imgOld),imagesy($imgOld));
    }
    else
    {
    imagecopyresized($imgObj,$imgOld,0,0,0,0,$width-100,$height-100,imagesx($imgOld),imagesy($imgOld));
    }
    imagedestroy($imgOld);
    unlink($fileName);
    imagejpeg($imgObj,$fileName,100);
    chmod($fileName,0777);
    imagedestroy($imgObj);
 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478444.htmlTechArticle删除了原始图片保留了操作后的图片 /*** Reduce image function * @param string $fileName * @return void*/ private function createSmallImg($fileName) { list($width,$heigh...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template