我在 ubuntu 32 位中使用 laravel 4.2 图像干预。它正在工作,但图像未针对指定高度调整大小。假设我正在尝试调整 to 的图像大小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);
}