2016-11-14 11 views
0

laravel介入プラグインを使用しようとしています。問題なくインストールしましたが使えません。 サイズ変更されたイメージを返すテスト関数を作成しようとしていますが、成功しません。 問題はイメージパスにある可能性があります、私のコードを修正するのを助けてください。Laravel介入/画像は画像のサイズを変更しません

function test($img) 
 
{ 
 
    /* $img = Image::make('public/image1.jpg'); 
 
    $img->resize(300, 200); 
 
    return $img; */ 
 

 
    $image = Image::make('http://localhost/cms/digital-cms/public/image1.jpg')->resize(200, 200, function ($c) { 
 
     $c->aspectRatio(); 
 
     $c->upsize(); 
 
    }); 
 
    return $image; 
 

 
    //$h=200; $w=200; 
 
    //return Image::make(public_path('public/image1.jpg')->resize($h, $w)->response('jpg')); 
 
}

答えて

0

あなたは画像

$image = Image::make('http://localhost/cms/digital-cms/public/image1.jpg')->resize(200, 200, function ($c) { 
    $c->aspectRatio(); 
    $c->upsize(); 
}); 
return $image->response(); 
+0

を返すためにImageクラス上の応答関数を使用する必要がありますあなたの時間と助けを求め版にありがとうございました。 私はそれを変更しましたが、結果は同じです。 もし私がdd($ image-> response())を書くならば; こちらの画像をご覧ください。 http://imgur.com/a/LJA8s – Kabaneri

+0

これはlaravelレスポンスオブジェクトです。私に実際の応答の画像を送った – Kliment

+0

空を返します。 – Kabaneri

0
//get image 
$image=$request->file('image'); 
//rename image 
$input = time().'.'.$image->getClientOriginalExtension(); 
      //your directory to upload 
      $destinationPath = 'main/images/company'; 
      //save and resize image 
      $img = Image::make($image->getRealPath()); 
      $img->resize(20,20, function ($constraint) { 
       $constraint->aspectRatio(); 
       })->save($destinationPath.'/'.$input); 
関連する問題