Php laravel 4.2图像干预未针对指定高度正确调整尺寸
我正在ubuntu 32位中使用Laravel4.2图像干预。它正在工作,但图像未按指定高度调整大小。假设我试图将Php laravel 4.2图像干预未针对指定高度正确调整尺寸,php,laravel,laravel-4.2,Php,Laravel,Laravel 4.2,我正在ubuntu 32位中使用Laravel4.2图像干预。它正在工作,但图像未按指定高度调整大小。假设我试图将width=800,height=600的图像调整为width=250,height=250,但它正在调整为width=250,height=188 我在控制器中使用了以下代码 $imageType = array( 'detail_page' => array( 'width' => 250, 'height' => 250 ), );
width=800,height=600
的图像调整为width=250,height=250
,但它正在调整为width=250,height=188
我在控制器中使用了以下代码
$imageType = array(
'detail_page' => array(
'width' => 250,
'height' => 250
),
);
$file = Input::file('album_image');
if($file->isValid()) {
$file_name = microtime();
$file_name = str_replace(' ', '_', $file_name);
$file_name = str_replace('.', '_', $file_name);
$file_name = $file_name . '.' . $file->getClientOriginalExtension();
$file->move(public_path() . '/album_uploads/', $file_name);
foreach ($imageType as $key => $value) {
$file = Image::make(sprintf('album_uploads/%s',$file_name))->resize($value['width'], $value['height'],
function($constraint) {
$constraint->aspectRatio();
});
$file->save(public_path().'/album_uploads/'.$value['width'].'X'.$value['height'].'/'. $file_name);
}
$album_image_url = URL::to('album_uploads/' . $file_name);
}
删除纵横比约束:800x600->250x188->4x3
function($constraint) {
$constraint->aspectRatio();
}