Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jim1506's avatar

5.3 - Image source not readable

I have saved an image and wish to make a thumbnail. Using the 5.3 I have used: $path = $request->file('image')->store('public/users'); Now the idea is to make a thumbnail. I have the following code: $file = substr(strrchr($path, '/'), 1); $tpath = 'public/users/thumbs/'.$file; $image = \Image::make(public_path($path))->resize(100, 100); but I get the following error message: NotReadableException in AbstractDecoder.php line 302: Image source not readable The uploaded file is readable as I have writtena view which displays it OK. Any ideas please?

0 likes
5 replies
JoolsMcFly's avatar

What's the output of public_path($path)? Why aren't you just using $path?

Also, instead of $file = substr(strrchr($path, '/'), 1); you can use basename: $file = basename($path);

jim1506's avatar

I used public_path as a trial from something on Stackoverflow, but that was about Laravel 4.

I dropped the public path so it reads:

$image = \Image::make($tpath)->resize(100, 100);

and the output (with dd) is

"public/users/4e72240ea18de7687ced7705ef4b1a33.jpeg"

which is correct and the file is readable, but I am still getting

NotReadableException in AbstractDecoder.php line 302:

What I am trying to do now is to read it and make it into a 200x200 thumb to be stored in /public/users/thumbs.

Help is greatly appreciated indeed!

I

jim1506's avatar
jim1506
OP
Best Answer
Level 3

Well there was a better solution as I simply could not get this to work. This way there is no generation of thumbnail as jQuery does it on the fly (http://www.garralab.com/nailthumb-examples.php)

simply by adding two files to the master layout (assuming jQuery is loaded):

  <link rel="stylesheet" src="{{ asset('css\jquerynailthumb.1.1.css') }}" type="text/css" />
<script type="text/javascript" src="{{ asset('js/jquery.nailthumb.1.1.min.js') }}"></script>

and defining a bit of css:

.square-thumb-60 {
        width: 60px;
        height: 60px;
    }

It is just then a case of jQuery's document ready adding:

$('.nailthumb-container').nailthumb();

and wrapping the required photo in a div:

@if ($user->image <> '')
                                     <div class="nailthumb-container square-thumb-60">
                                         <img src="{{Storage::url( $user->image )}} "/>
                                     </div>
                                @endif

Works perfectly and there are other options for the JavaScript.

Highly recommended!

1 like
AhmadYousef's avatar

@jim1506 , This will not make a low size images, it will simply just resize their height and width or crop them with CSS, if you have a large image say 2 MB, it will still load the image in that size.

read this from the JQuery NailThumb website :

This plugin won't help you deliver very big high-res images more easily. If you have very big images and wish to have lower size thumbnails you'll still have to batch resize them before hand. There is no way this can be done client side via javascript.

Please or to participate in this conversation.