How to use the cairocffi.pixbuf.decode_to_image_surface function in cairocffi

To help you get started, we’ve selected a few cairocffi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kozea / cairocffi / cairocffi / test_pixbuf.py View on Github external
def test_api():
    with pytest.raises(pixbuf.ImageLoadingError):
        pixbuf.decode_to_image_surface(b'')
    with pytest.raises(pixbuf.ImageLoadingError):
        pixbuf.decode_to_image_surface(b'Not a valid image.')
    with pytest.raises(pixbuf.ImageLoadingError):
        pixbuf.decode_to_image_surface(PNG_BYTES[:10])
    surface, format_name = pixbuf.decode_to_image_surface(PNG_BYTES)
    assert format_name == 'png'
    assert_decoded(surface)
github Kozea / cairocffi / cairocffi / test_pixbuf.py View on Github external
def test_api():
    with pytest.raises(pixbuf.ImageLoadingError):
        pixbuf.decode_to_image_surface(b'')
    with pytest.raises(pixbuf.ImageLoadingError):
        pixbuf.decode_to_image_surface(b'Not a valid image.')
    with pytest.raises(pixbuf.ImageLoadingError):
        pixbuf.decode_to_image_surface(PNG_BYTES[:10])
    surface, format_name = pixbuf.decode_to_image_surface(PNG_BYTES)
    assert format_name == 'png'
    assert_decoded(surface)
github Kozea / cairocffi / cairocffi / test_pixbuf.py View on Github external
def test_api():
    with pytest.raises(pixbuf.ImageLoadingError):
        pixbuf.decode_to_image_surface(b'')
    with pytest.raises(pixbuf.ImageLoadingError):
        pixbuf.decode_to_image_surface(b'Not a valid image.')
    with pytest.raises(pixbuf.ImageLoadingError):
        pixbuf.decode_to_image_surface(PNG_BYTES[:10])
    surface, format_name = pixbuf.decode_to_image_surface(PNG_BYTES)
    assert format_name == 'png'
    assert_decoded(surface)
github qtile / qtile / libqtile / images.py View on Github external
def _decode_to_image_surface(bytes_img, width=None, height=None):
    try:
        surf, fmt = cairocffi.pixbuf.decode_to_image_surface(bytes_img, width, height)
        return _SurfaceInfo(surf, fmt)
    except TypeError:
        from .log_utils import logger
        logger.exception(
            "Couldn't load cairo image at specified width and height. "
            "Falling back to image scaling using cairo. "
            "Need cairocffi > v0.8.0"
        )
        surf, fmt = cairocffi.pixbuf.decode_to_image_surface(bytes_img)
        return _SurfaceInfo(surf, fmt)
github qtile / qtile / libqtile / images.py View on Github external
def _decode_to_image_surface(bytes_img, width=None, height=None):
    try:
        surf, fmt = cairocffi.pixbuf.decode_to_image_surface(bytes_img, width, height)
        return _SurfaceInfo(surf, fmt)
    except TypeError:
        from .log_utils import logger
        logger.exception(
            "Couldn't load cairo image at specified width and height. "
            "Falling back to image scaling using cairo. "
            "Need cairocffi > v0.8.0"
        )
        surf, fmt = cairocffi.pixbuf.decode_to_image_surface(bytes_img)
        return _SurfaceInfo(surf, fmt)
github mjkillough / set-wallpaper / set_wallpaper.py View on Github external
def load_image(path):
    with open(path, 'rb') as f:
        surface, mimetype = cairocffi.pixbuf.decode_to_image_surface(f.read())
        return surface