1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| function resize($file){
$path = $this->f.'/'.$file;
$imgSrc = imagecreatefromjpeg($path);
list($width,$height) = getimagesize($path);
$this->setRatio($width,$height);
$newImg = imagecreatetruecolor($this->w,$this->h);
//imagecopyresampled($newImg,$imgSrc,0,0,0,0,$this->w,$this->h,$width,$height);
imagecopyresized($newImg, $imgSrc, 0, 0, 0, 0, $this->w, $this->h, $width, $height);
if (imagejpeg($newImg,$this->newFolderName)){ //** ne fonctionne pas ****
//if (imagejpeg($newImg)){ //** fonctionne bien ****
imagedestroy($imgSrc);
imagedestroy($newImg);
return true;
}
else {
imagedestroy($imgSrc);
imagedestroy($newImg);
return false;
}
} |
Partager