PK_06's avatar
Level 1

Image Intervention

Hi Everyone,

Can you help me with this problem? Unable to decode image from file And I got this exception Intervention\Image\Exception\NotReadableException

Im using Image Intervention package to process thumbnail size images. It is working with smaller images but it seems that error/exception appearing if images are 180mb+.

Im using those configuration to manipulate php_ini configs.

php_value upload_max_filesize 800M
php_value post_max_size 1000M
php_value memory_limit 10800M
php_value max_execution_time 3600

I wil also share my test code.

//get filename with extension
$filenamewithextension = $request->file('file_name')->getClientOriginalName();
 
//get filename without extension
$filename = pathinfo($filenamewithextension, PATHINFO_FILENAME);
 
//get file extension
$extension = $request->file('file_name')->getClientOriginalExtension();
 
//filename to store
$filenametostore = $filename.'_'.time().'.'.$extension;

$request->file('file_name')->storeAs('public/thumbnail', $filenametostore);
 
//Resize image here
$thumbnailpath = public_path('storage/thumbnail/'.$filenametostore);

$img = Image::make($thumbnailpath)
->resize(400, 150, function($constraint) {
     $constraint->aspectRatio();
 });

$img->save($thumbnailpath);

return response('Successfully Uploaded', 200);

Any suggestions are highly appreciated! Thank you!

0 likes
5 replies
edoc's avatar

you are passing a string. change this part of code like this and try Image::make($request->file('file_name'))

PK_06's avatar
Level 1

@EDOC - @edoc I already tried that part. Also

$request->file('file_name')->getRealPath();
edoc's avatar

$img = Image::make($request->file('file_name'))
->resize(400, 150, function($constraint) {
     $constraint->aspectRatio();
 });

you don't need getRealPath();

@PK_06

PK_06's avatar
Level 1

@EDOC - @edoc same result happens.

Unable to decode image from file (C:\wamp64\tmp\phpD9C1.tmp).
C:\wamp64\www\dealer_data_portal\vendor\intervention\image\src\Intervention\Image\Gd\Decoder.php#63

if (empty($core)) {
            throw new \Intervention\Image\Exception\NotReadableException(
                "Unable to decode image from file ({$path})."
            );
        }
PK_06's avatar
Level 1

Im fixing it about 2 days. And it is really not good.

Please or to participate in this conversation.