Error – “Unable to init from given binary data” in Laravel backpack and docker environment

I’m getting this error when uploading jpeg/jpg images. But it works for PNG images. The same code is working on a different server with the same PHP installation. But it is a standard AWS deployment. Currently I’m checking on the dockerized environment. Code as follows:

{

        // 1. Generate a filename.

        $filename = Carbon::now()->format('Y-m-d-His').'.'.'.jpg';

        // 2. Store the image on disk.

        $imageUid = $destination_path.'/'.$filename;

        list($type, $imageData) = explode(';', $value);

        list($type, $imageData) = explode(',', $value);

        $imageData = base64_decode($imageData);

        Storage::disk($disk)->put($imageUid, $imageData);

        // 3. Save the path to the database

        $this->attributes[$attribute_name] = $destination_path.'/'.$filename;



        $thumbImageName = '/thumb-'.basename($imageUid);

        $thumbMiniImageName = '/thumb-mini-'.basename($imageUid);

        $path = 'uploads/user/image/'.$this->uuid;

        $thumbMini = Image::make(env('AWS_S3_URL')  .$imageUid)->fit(56,56)->stream();

        $thumb = Image::make(env('AWS_S3_URL')  .$imageUid)->fit(140,140)->stream();



        Storage::disk('s3')->put($path.$thumbImageName,$thumb->__toString());

        Storage::disk('s3')->put($path.$thumbMiniImageName,$thumbMini->__toString());



        $this->attributes['thumb_uid'] = $path.$thumbImageName;

        $this->attributes['thumb_mini_uid'] = $path.$thumbMiniImageName;

    }

I’m getting error in this line

$thumbMini = Image::make(env('AWS_S3_URL')  .$imageUid)->fit(56,56)->stream();

Sample Image data

"image_uid": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQANq7/Z",

Docker php extensions

RUN apt update && apt install -y supervisor wget git openssh-server unzip postgresql-client libfreetype6-dev libjpeg62-turbo-dev libpq-dev libzip-dev libpng-dev libonig-dev libxml2-dev libcurl4-openssl-dev libssl-dev libjpeg-dev curl cron --no-install-recommends 
        && docker-php-ext-install sockets zip opcache pdo_pgsql mbstring exif gd && docker-php-ext-configure pdo_pgsql --with-pdo-pgsql=/usr/ && docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/

enter image description here

PHP – 8.2.7
Laravel – 10.44.0

Can you please a solution if anyone have same experience on this?