Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When run from Docker - Fatal error: Uncaught Intervention\Image\Exception\NotReadableException: Unable to init from given binary data #1

Closed
soup-bowl opened this issue Nov 3, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@soup-bowl
Copy link
Owner

When you run the Docker image, you get hit with the following:

Attaching to lastfm-twitter_bot_1
bot_1  | - Scraping from last.fm...
bot_1  | - Generating collage...
bot_1  | 
bot_1  | Fatal error: Uncaught Intervention\Image\Exception\NotReadableException: Unable to init from given binary data. in /opt/tbot/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php:131
bot_1  | Stack trace:
bot_1  | #0 /opt/tbot/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php(82): Intervention\Image\Gd\Decoder->initFromBinary('\xFF\xD8\xFF\xE0\x00\x10JFIF\x00\x01\x01\x00\x00...')
bot_1  | #1 /opt/tbot/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php(335): Intervention\Image\AbstractDecoder->initFromUrl('https://lastfm....')
bot_1  | #2 /opt/tbot/vendor/intervention/image/src/Intervention/Image/AbstractDriver.php(66): Intervention\Image\AbstractDecoder->init('https://lastfm....')
bot_1  | #3 /opt/tbot/vendor/intervention/image/src/Intervention/Image/ImageManager.php(54): Intervention\Image\AbstractDriver->init('https://lastfm....')
bot_1  | #4 /opt/tbot/vendor/intervention/image/src/Intervention/Image/ImageManagerStatic.php(58): Intervention\Image\ImageManager->make('https://lastfm....')
bot_1  | #5 /opt/tbot/vendor/tzsk/collage/src/Con in /opt/tbot/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php on line 131
lastfm-twitter_bot_1 exited with code 255

Presumably this is coming from the fact the Collage process is fed image URLs, rather than a local system or binary collection. Might need to rejig the import handler to see why this doesn't work. When tried on a local system running Kubuntu 20.04, it works fine.

Possibly related: Intervention/image#634

@soup-bowl soup-bowl added the bug Something isn't working label Nov 3, 2021
@soup-bowl soup-bowl self-assigned this Nov 3, 2021
@soup-bowl
Copy link
Owner Author

This might be the reason why it's happening, but I'm still only experiencing this in Docker only.
Screenshot_20211104_233725

@soup-bowl
Copy link
Owner Author

There's this function in vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php:

/**
     * Initiates new image from binary data
     *
     * @param  string $data
     * @return \Intervention\Image\Image
     */
    public function initFromBinary($binary)
    {
        $resource = @imagecreatefromstring($binary);

        if ($resource === false) {
             throw new NotReadableException(
                "Unable to init from given binary data."
            );
        }

        $image = $this->initFromGdResource($resource);
        $image->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $binary);

        return $image;
    }

imagecreatefromstring appears to be returning false on webp in my Docker image. This implies a problem with the libgd library provided with the underlying container OS than a problem with the code itself.

@soup-bowl
Copy link
Owner Author

I've replaced the Docker build with CentOS 7. Rather a dramatic change, but since I'm (at least now) the only user and the mainline PHP build has problems I can use that + remirepo from familiarity.

This now works on Intel/AMD. Yet to test on ARM, but issue can be closed for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant