skia-python

raw JSON →
144.0.post2 verified Mon Apr 27 auth: no python

Python bindings for the Skia 2D graphics library. Current version is 144.0.post2, released on 2025-04-28. The project tracks upstream Skia milestones (currently m144) and releases irregularly, often with significant API changes between milestones.

pip install skia-python
error ImportError: libEGL.so.1: cannot open shared object file: No such file or directory
cause Missing libEGL shared library on Linux. Required since v87.9rc1/v138.0rc1.
fix
Install libegl1 (Ubuntu/Debian: sudo apt install libegl1, Fedora: sudo dnf install mesa-libEGL)
error AttributeError: module 'skia' has no attribute 'ApplyPerspectiveClip'
cause ApplyPerspectiveClip removed in Skia m138+.
fix
Remove references to skia.ApplyPerspectiveClip and adapt code to use fewer arguments in related APIs.
error TypeError: incReserve() takes 2 positional arguments but 3 were given
cause skia.PathBuilder.incReserve signature changed: now takes an extra argument.
fix
Check Skia docs for new signature (likely incReserve(self, count, extra)). Pass the required additional argument.
error ModuleNotFoundError: No module named 'numpy'
cause numpy is a required dependency for pixel operations and image I/O.
fix
Install numpy: pip install numpy
error skia.pdf: Metadata() got an unexpected keyword argument 'jpegEncoder'
cause Old code passing jpegEncoder to Metadata() constructor; new Metadata() initializes with default codecs.
fix
Use skia.PDF.Metadata() without arguments and set jpegEncoder/jpegDecoder as attributes if needed.
breaking Vulkan APIs now require skia.VkFormat and skia.VkImageLayout enums instead of integer constants. Code using raw Vulkan integer values will break.
fix Replace integer values with skia.VkFormat.* and skia.VkImageLayout.*, e.g. skia.VkFormat.kR8G8B8A8_UNORM_VK_FORMAT.
breaking skia.ApplyPerspectiveClip removed upstream. Associated APIs take one fewer argument.
fix Remove the perspective clip argument from affected API calls. Check Skia release notes for exact API changes.
breaking skia.PathBuilder.incReserve now takes one more argument (count plus unknown parameter).
fix Add the extra argument to incReserve calls. Refer to Skia upstream docs for new signature.
gotcha Linux users must have libEGL.so installed (from mesa-libEGL, libglvnd, or Nvidia drivers) or import will fail.
fix Install mesa-libEGL (e.g., sudo apt install libegl1 on Debian/Ubuntu) or ensure libEGL.so is in library path.
deprecated skia.PDF.MakeDocument() signature changed: jpegEncoder and jpegDecoder fields are now required in Metadata. The zero-argument skia.PDF.Metadata() now includes default JPEG codecs.
fix Use skia.PDF.Metadata() without arguments for defaults, or supply jpegEncoder/jpegDecoder callables.
gotcha Numpy dependency is required; missing numpy leads to import errors in pixel operations.
fix Install numpy: pip install numpy

Basic example: create a surface, draw a red rectangle, and save as PNG.

import skia
import os

# Create 256x256 red canvas
surface = skia.Surface(256, 256)
with surface as canvas:
    paint = skia.Paint(color=skia.ColorRED, style=skia.Paint.kFill_Style)
    canvas.drawRect(skia.Rect(10, 10, 100, 100), paint)

# Save to PNG
image = surface.makeImageSnapshot()
image.save('output.png', skia.kPNG)
print('Image saved as output.png')