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

masandikdev's avatar

Skip Not Readable Images

Hi all, i have problem with skip images that not readable.

i use Intervention https://github.com/Intervention/image/

how i skip to save image if image source is not readable. can you give me logical code how to check it.

thanks

0 likes
3 replies
stefanbauer's avatar

As it seems, there will an exception be thrown if image could not be loaded. Just catch that exception.

masandikdev's avatar

@StefanBauer how to implement it anyway, im new on php. :)

i have simple code like this

$img    = Image::make($media->source)->resize($width, $height);
$img->save(public_path($image['path']));

i loop it, example 10 loop.

if error happen in 3rd, looping will stop and i fail get the last 7 images.

what i want is just skip image that not readable, and continue execute the looping.

any suggestion how to implement it. thanks

masandikdev's avatar

just figure it out, because using namespace i should use \Exception or using use Exception at top.

thanks @StefanBauer for suggestion.

Please or to participate in this conversation.