Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php laravel 4.2图像干预未针对指定高度正确调整尺寸_Php_Laravel_Laravel 4.2 - Fatal编程技术网

Php laravel 4.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 ), );

我正在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      
  ),
);

$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();
}