简体   繁体   中英

Laravel Call to undefined function Intervention\Image\Gd\imagecreatefrompng()

Hi I am using glide ( http://glide.thephpleague.com/ ) for image manipulation in my laravel project. I am facing an issue when storing an Image. "Call to undefined function Intervention\\Image\\Gd\\imagecreatefrompng() "

The strange thing is that I can open the image with "preview" on my mac. But not in the browser. Also Photoshop tells me that there is something wrong with this file, it's corrupt.

this is how I save the image in a private folder:

public function update(Request $request, $id)
{

  //Show the image
  echo '<img src="'.$_POST['img_val'].'" />';

  //Get the base-64 string from data
  $filteredData=substr($_POST['img_val'], strpos($_POST['img_val'], ",")+1);

  //Decode the string
  $unencodedData=base64_decode($filteredData);

  //Save the image
  $storagepath = storage_path('app/images/users/' . Auth::user()->id);
  $imgoutput = File::put($storagepath.'/flyer.jpg', $unencodedData);

  return view('backend.flyers.index')->withImgoutput($imgoutput);
                                     //->withStoragepath($storagepath);

}

It seems like File::put(XXX. jpg ) JPG causes the problem. How can I fix this?

This is because the GD Library is missing. Try this:

You must enable the library GD2.

Find your (proper) php.ini file

Find the line: ;extension=php_gd2.dll and remove the semicolon in the front.

The line should look like this:

extension=php_gd2.dll

Then restart apache and you should be good to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM