1
この機能を使用してJpgまたはPngファイルからサムネイルを作成しようとすると、非常に不満な問題が発生しています。メモリサイズを使い果たしました - Imagecreatetruecolour();
時々動作し、ときどき動作しないことがあります。私はメモリリークを持っている必要がありますと思いますが、私はそれを引き起こしているかわからないんだけど、オンラインアップ読め
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 8192 bytes) in * on line 34
:それは動作しない場合は、私は次のエラーを取得します。ここで
機能は次のとおりです。
function make_thumb($src, $dest, $desired_width) {
$fileType = pathinfo($src, PATHINFO_EXTENSION);
echo $fileType;
if ($fileType == 'JPG' || $fileType == 'JPEG' || $fileType == 'jpg' || $fileType == 'jpeg') {
$source_image = imagecreatefromjpeg($src);
} else if ($fileType == 'PNG' || $fileType == 'png') {
$source_image = imagecreatefrompng($src);
} else {
return false;
}
$width = imagesx($source_image);
$height = imagesy($source_image);
$desired_height = floor($height * ($desired_width/$width));
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
imagejpeg($virtual_image, $dest);
return true;
}
ありがとう!
は[imagedestroy](http://php.net/manual/en/function.imagedestroy.php)そのため – jszobody
感謝を参照してください!私はimagecreatetruecolorラインの後、または機能の終わりにそれをまっすぐに置くことができますか? – georgewoofbates