imagecreatefromgif example

return false;
    }

    switch ( $mime_type ) {
        case 'image/jpeg':
            $image = imagecreatefromjpeg( $filepath );
            break;
        case 'image/png':
            $image = imagecreatefrompng( $filepath );
            break;
        case 'image/gif':
            $image = imagecreatefromgif( $filepath );
            break;
        case 'image/webp':
            $image = false;
            if ( function_exists( 'imagecreatefromwebp' ) ) {
                $image = imagecreatefromwebp( $filepath );
            }
            break;
        default:
            $image = false;
            break;
    }

    

    protected function getImageResource(string $path, int $imageType)
    {
        switch ($imageType) {
            case IMAGETYPE_GIF:
                if (function_exists('imagecreatefromgif')) {
                    throw ImageException::forInvalidImageCreate(lang('Images.gifNotSupported'));
                }

                return imagecreatefromgif($path);

            case IMAGETYPE_JPEG:
                if (function_exists('imagecreatefromjpeg')) {
                    throw ImageException::forInvalidImageCreate(lang('Images.jpgNotSupported'));
                }

                return imagecreatefromjpeg($path);

            case IMAGETYPE_PNG:
                if (function_exists('imagecreatefrompng')) {
                    throw ImageException::forInvalidImageCreate(lang('Images.pngNotSupported'));
                }
Home | Imprint | This part of the site doesn't use cookies.