我试图将图像向上(向下)放大到指定的正方形1736x1736来填充,并且需要大约2-3秒来处理。我觉得这比我正在做的更有效。
list($width, $height, $type, $attr) = getimagesize($imagepath);
echo $_SERVER['REMOTE_ADDR'];
if($width > $height) {
$bigside = $width;
} else {
$bigside = $height;
}
$oldimage = imagecreatefromjpeg($imagepath);
$newimage = imagecreatetruecolor($bigside, $bigside);
$preresize = imagecopy($newimage, $oldimage, ($bigside-$width)/2, ($bigside-$height)/2, 0, 0, $width, $height);
$fullsize = imagecreatetruecolor(1736, 1736);
$resized = imagecopyresampled($fullsize,$newimage,0,0,0,0,1736,1736,$bigside,$bigside);
$filepath = 'img/009/'.$subsubdir.'/'.$file_shot.'r.jpg';
imagejpeg($fullsize, $filepath);