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

Driver GdImage : supports more image types #1

Open
MKCG opened this issue Dec 31, 2021 · 0 comments
Open

Driver GdImage : supports more image types #1

MKCG opened this issue Dec 31, 2021 · 0 comments

Comments

@MKCG
Copy link
Owner

MKCG commented Dec 31, 2021

GdImage::createImageDescriptor( throws an Exception when it can not determine the number of channels used by the image to encode.

switch (mime_content_type($filepath)) {
    case "image/jpeg":
        break;

    case "image/png":
        $marker = file_get_contents($filepath, false, null, 25, 1);
        $channels = match(ord($marker)) {
            2, 3 => 3,
            6 => 4,
            default => throw new DriverException(),
        };

        break;

    case "image/webp":
    default: throw new DriverException();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant