要获得具有精确尺寸的图像(即添加空白),请使用 borderImage
$desired_width = 1000;
$desired_height = 1000;
$image->scaleImage($desired_width,$desired_height , true);
$image->borderImage('white', ($image->getImageWidth() - $desired_width) / 2,($image->getImageHeight() - $desired_height ) / 2);