Skip to content

Driver GdImage : supports more image types  #1

Description

@MKCG

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();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions