ねえ、私はPHPでtemporayサムファイルを作成する方法を探しています。サーバーに画像を保存したり、すぐに削除したりしない方法はありますか?私が探しているのは、次のようなソリューションです。http
://www.dig2go.com/index.php?shopbilde=772&type=1&size=
120この背後にあるphpコードがどのように機能するかを誰かに説明してもらえますか?今のところ、サムネイルの作成にネット上で見つけたphpコードを使用しています。
function createThumb($pathToImage, $pathToThumb, $thumbWidth, $thumbHeight, $saveNameAndPath)
{
if(!file_exists($pathToImage))
return false;
else
{
//Load image and size
$img = imagecreatefromjpeg($pathToImage);
$width = imagesx($img);
$height = imagesy($img);
//Calculate the size of thumb
$new_width = $thumbWidth;
$new_height = $thumbHeight; //floor($height * ($thumbWidth / $width));
//Make the new thumb
$tmp_img = imagecreatetruecolor($new_width, $new_height);
//Copy the old image and calculate the size
imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
//Save the thumb to jpg
imagejpeg($tmp_img, $saveNameAndPath);
return true;
}
}