Python binding to Skia Graphics Library

Overview

Skia python binding

Build and test PyPI version

Python binding to Skia Graphics Library.

Currently, the binding is under active development.

Install

Binary package is available on PyPI:

pip install skia-python

Supported platforms:

  • Linux x86_64, aarch64
  • macOS x86_64, arm64
  • Windows x86_64

For Linux platforms, there must be OpenGL and fontconfig installed:

apt-get install libfontconfig1 libgl1-mesa-glx libgl1-mesa-dri

Or:

yum install fontconfig mesa-libGL mesa-dri-drivers

For unsupported environment, check the build instruction.

Examples

Documentation

https://kyamagu.github.io/skia-python

Contributing

Feel free to post an issue or PR.

Comments
  • Wheels broken on OS-X

    Wheels broken on OS-X

    When I install via pip, I get the wheels published on PyPi. Example:

    skia_python-87.1-cp39-cp39-macosx_10_14_x86_64.whl

    However, they don't work :-( Erroring out on import with:

    ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/skia.cpython-39-darwin.so, 2): Symbol not found: _XML_ErrorString
      Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/skia.cpython-39-darwin.so
      Expected in: flat namespace
     in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/skia.cpython-39-darwin.so
    

    Tested under the Python.org 3.9 installer, and conda-forge 3.8 and 3.9 -- same results on all three.

    It seems that it's looking for the _XML_ErrorString symbol from expat, which is bundled with Python:

    $ python -c "import xml.parsers.expat; print xml.parsers.expat.__version__"
    $Revision: 17640 $
    

    I'm totally guessing but I think it might be the "flat namespace" issue. The symbol is there in the extension:

    $ grep "_XML_ErrorString" /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/pyexpat.cpython-39-darwin.so 
    Binary file /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/pyexpat.cpython-39-darwin.so matches
    

    Sorry -- I've reached the end of what I know about these issues.

    bug 
    opened by ChrisBarker-NOAA 16
  • AttributeError: type object 'skia.GrContext' has no attribute 'MakeGL'

    AttributeError: type object 'skia.GrContext' has no attribute 'MakeGL'

    Describe the bug Example in docs raises exception

    To Reproduce Steps to reproduce the behavior:

    1. pip install skia-python==86.0 glfw==1.12.0
    2. run example from tutorial: https://kyamagu.github.io/skia-python/tutorial/canvas.html#gpu
    3. Get error:
    AttributeError: type object 'skia.GrContext' has no attribute 'MakeGL'
    

    Expected behavior Working example in documentation

    Desktop (please complete the following information):

    • OS: Linux
    • Python: 3.8
    • skia-python version: 86.0
    opened by FlorianLudwig 7
  • ERROR: No matching distribution found for skia-python==87.4 when building docker with Apple M1

    ERROR: No matching distribution found for skia-python==87.4 when building docker with Apple M1

    Describe the bug As described in the title, when building docker image on Apple M1, I get the error above. I'm using python:3.10.2 image, but got the same error with ubuntu:18.04 image

    To Reproduce Steps to reproduce the behavior:

    1. Run docker build and try installing skia-python

    Expected behavior Build success

    Desktop (please complete the following information):

    • OS: macOS 12.2
    • Python: 3.10.2
    • skia-python version: v87.4

    Additional context I tried: apt-get install libfontconfig1 libgl1-mesa-glx libgl1-mesa-dri but it did not help.

    Thank you! :)

    opened by Adir207 6
  • Init a scene by a function?

    Init a scene by a function?

    I am trying to use this brilliant package to make some functions/classes easier to use this package. I have one major issue and after reading the docs I can't seem to find the right solution. I'm looking to make a function that generates a scene to write to.. Something like this:

    
    import skia
    from IPython.display import display, Image
    
    def init_scene(x,y):
        surface = skia.Surface(x, y)
        with surface as canvas:
            canvas.clear(skia.ColorWHITE)
    
    def draw_cube_to_scene():
        rect = skia.Rect.MakeXYWH(-90.5, -90.5, 181.0, 181.0)
        paint = skia.Paint()
        paint.setColor(skia.ColorBLUE)
        canvas.drawRect(rect, paint)
        canvas.restore()
        image = surface.makeImageSnapshot()
        display(Image(data=image.encodeToData()))
    
    init_scene(500,200)
    draw_cube_to_scene()
    

    results in: ERROR name 'canvas' is not defined

    For the example to work the surface and canvas cannot be locally in a function/class. So this works:

    import skia
    from IPython.display import display, Image
    
    surface = skia.Surface(500, 200)
    with surface as canvas:
        canvas.clear(skia.ColorWHITE)
    
    def draw_cube_to_scene():
        rect = skia.Rect.MakeXYWH(-90.5, -90.5, 181.0, 181.0)
        paint = skia.Paint()
        paint.setColor(skia.ColorBLUE)
        canvas.drawRect(rect, paint)
        canvas.restore()
        image = surface.makeImageSnapshot()
        display(Image(data=image.encodeToData()))
    
    draw_cube_to_scene()
    

    Results in a nice cube image

    But now the user cannot create a new scene with custom size of graphics. Do you know it is possible to do the first example? I would love your help.

    question 
    opened by ReneTC 4
  • NumPy array with incorrect dtype silently proceeds

    NumPy array with incorrect dtype silently proceeds

    Describe the bug NumPy array conversion to, e.g., Image silently accepts array with types other than uint8.

    To Reproduce

    import skia
    import numpy as np
    
    array = np.zeros((100, 100), dtype=np.float32)
    image = skia.Image(array)
    

    Expected behavior Should throw an error.

    Desktop (please complete the following information):

    • OS: macOS 10.15.4
    • Architecture x86_64
    • Python 3.7
    • skia-python version v0.0.4

    Additional context n/a

    opened by kyamagu 4
  • Loading an image as paint

    Loading an image as paint

    Is it possible to draw an image on a "canvas.drawRect" object?

    I know you can do

    paint = skia.Paint(
        AntiAlias=True,
        Color=color,
        Style=skia.Paint.kFill_Style,
        )
    canvas.drawRect(skia.Rect.MakeXYWH(x,y, width, height), paint)
    

    Is there a commad in paint that allwos to load an image and display it on a rectangle?

    question 
    opened by ReneTC 3
  • Broken skia build

    Broken skia build

    Describe the bug Windows CI build fails

    To Reproduce Launch build in Github Actions windows runner

    Expected behavior Build should succeed.

    Desktop (please complete the following information):

    • OS: macOS 10.15.6
    • Python: n/a
    • skia-python version: v85.0

    Additional context See https://skia.googlesource.com/skia/+/0d6f81593b1fa222e8e4afb56cc961ce8c9be375

    https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes#16.7.0 https://github.com/microsoft/STL/wiki/Changelog#vs-2019-167

    bug 
    opened by kyamagu 3
  • How to output skia on a glfw window

    How to output skia on a glfw window

    I have been trying to output the skia drawing on glfw window. This is the code I have (not working):

    import skia
    import glfw
    import contextlib
    import time
    
    width, height = 200, 200
    
    if not glfw.init():
        raise RuntimeError('glfw.init() failed')
    
    #glfw.window_hint(glfw.VISIBLE, glfw.FALSE)
    glfw.window_hint(glfw.STENCIL_BITS, 8)
    window = glfw.create_window(640, 480, 'Processing', None, None)
    glfw.make_context_current(window)
    
    context = skia.GrContext.MakeGL()
    info = skia.ImageInfo.MakeN32Premul(width, height)
    surface = skia.Surface.MakeRenderTarget(context, skia.Budgeted.kNo, info)
    canvas = surface.getCanvas()
    canvas.drawCircle(100, 100, 40, skia.Paint(Color=skia.ColorGREEN))
    
    # Loop until the user closes the window
    while not glfw.window_should_close(window):
        # Render here, e.g. using pyOpenGL
    
        # Swap front and back buffers
        glfw.swap_buffers(window)
    
        # Poll for and process events
        glfw.poll_events()
    
    glfw.terminate()
    

    Is there anything that can be done to make this work?

    question 
    opened by parsoyaarihant 3
  • Add examples of interaction with Pillow & Wand & fs

    Add examples of interaction with Pillow & Wand & fs

    Is your feature request related to a problem? Please describe. I'm a beginner at Python and have been looking as Skia recently and wanted to use some of it's unique features. This is the first(only?) python library that seems to be complete that i found. Could you please add some examples of interaction or exchange of information with Pillow and Wand. And also saving or reading from files. ie eliminate use of ipython calls.

    Describe the solution you'd like Examples

    • Read from file.
    • Add skia content.
    • Do Pillow / Wand content to 'canvas'
    • Add skia content.
    • Save to a file(skia)

    Describe alternatives you've considered Could not get the Ipython package working on my system so was a bit lost of how to use skia-python. it does appear to work but can't show or display or save to file.

    enhancement 
    opened by cdplayer 3
  • pip install skia-python fails on py3.10, works fine on py3.9

    pip install skia-python fails on py3.10, works fine on py3.9

    Describe the bug skia-python can't be installed using python 3.10 and pip

    To Reproduce Steps to reproduce the behavior:

    1. Install Python 3.10
    2. python -m pip install skia-python

    Expected behavior skia-python is installed

    Actual behavior ERROR: Could not find a version that satisfies the requirement skia-python (from versions: none)

    Desktop (please complete the following information):

    • OS: Windows 11 21H2
    • Python: 3.10.0
    • skia-python version: n/a

    Additional context In the same environment (hardware and OS) installation with pip on python 3.9 works fine. I believe the issue is that 3.10 is not in the list of supported versions (although I couldn't find the list itself).

    enhancement 
    opened by evtn 2
  • How to use drawVerticies?

    How to use drawVerticies?

    Im trying to make a triangle. Seems like the best way to do this is with drawVertices. However, I can't get this to work and there are not any examples. I would love your input on this.

    import skia
    from IPython.display import display
    surface = skia.Surface(256, 256)
    
    with surface as canvas:
        color = skia.ColorSetRGB(0, 0, 0)
    
        paint = skia.Paint(Color=skia.Color(0, 0, 255))
    
        p1 = skia.Point(0, 0)
        p2 = skia.Point(100, 0.0)
        p3 = skia.Point(50, 100)
    
        test = skia.Vertices([p1,p2,p3])
        Canvas.drawVertices(test,paint)
    
    image = surface.makeImageSnapshot()
    display(image)
    

    I get the error

    
    TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
        1. skia.Vertices(mode: skia.Vertices.VertexMode, positions: List[skia.Point], texs: object = None, colors: object = None, indices: object = None)
    
    Invoked with: [Point(0, 0), Point(100, 0), Point(50, 100)]
    
    question 
    opened by ReneTC 2
  • AttributeError: type object 'skia.GrContext' has no attribute 'MakeGL'

    AttributeError: type object 'skia.GrContext' has no attribute 'MakeGL'

    Describe the bug I installed glfw, pyopengl, and the mesa glx and mesa dri packages etc. But no example from the documentation runs. I always get:

    AttributeError: type object 'skia.GrContext' has no attribute 'MakeGL'

    Desktop (please complete the following information):

    • OS: Ubuntu 22.10
    • Python: 3.10.7
    • skia-python version: 87.5
    opened by moefear85 3
  • Bindings are a bit outdated

    Bindings are a bit outdated

    The bindings weren't touched for some time. I've updated these to the latest version. Two major things changed in the API:

    • SamplingOptions
    • YUV-API

    I'm compiling these bindings by myself. I mean, this merge request does not contain "clean code" (please don't just merge it). but could be the basis for the next version. Using it here already: https://github.com/0lru/p3ui with d3d12 (d3d12 is also the reason for the update)

    opened by 0lru 6
  • AttributeError: 'NoneType' object has no attribute 'containerSize'?

    AttributeError: 'NoneType' object has no attribute 'containerSize'?

    I'm working on my project to create patterns from svg code, but I have problem. It turns out that documentation doesn't provide explanation why SVGDOM is returning none. Anyway, I provide simple code that I'm working, just a note if I use simple svg code of shape or something, then it's working but when I use code from inkscape or something else, this happens.

    I got this error...

    width, height = svg.containerSize()
    AttributeError: 'NoneType' object has no attribute 'containerSize'
    
    

    And this is code....

    import io
    import skia
    from PIL import Image
    
    
    def image_from_svg(svg, element_size):
        stream = skia.MemoryStream()
        stream.setMemory(bytes(svg, 'UTF-8'))
        svg = skia.SVGDOM.MakeFromStream(stream)
        width, height = svg.containerSize()
        surface = skia.Surface(element_size, element_size)
        with surface as canvas:
            canvas.scale(element_size / width, element_size / height)
            svg.render(canvas)
        return surface.makeImageSnapshot()
    
    
    def pattern_image_with_title(image_element, width, height, rotation):
        surface = skia.Surface(width, height)
        with surface as canvas:
            pattern(canvas, image_element, rotation)
        return surface.makeImageSnapshot()
    
    
    def pattern(canvas, image_element, rotation):
        matrix = skia.Matrix()
        matrix.preRotate(rotation)
        canvas.drawPaint({
            'Shader': image_element.makeShader(
                skia.TileMode.kRepeat,
                skia.TileMode.kRepeat,
                matrix,
            )
        })
    
    
    def write_png(file_name, skia_image):
        with io.BytesIO(skia_image.encodeToData()) as f:
            pil_image = Image.open(f)
            pil_image.save(file_name, 'PNG')
    
    
    def write_jpeg(file_name, skia_image, background):
        with io.BytesIO(skia_image.encodeToData()) as f:
            pil_image = Image.open(f)
            new_image = Image.new("RGBA", pil_image.size, background)
            new_image.paste(pil_image, (0, 0), pil_image)
            new_image = new_image.convert('RGB')
            new_image.save(file_name, 'JPEG')
    
    svg_code = """<svg
       width="210mm"
       height="297mm"
       viewBox="0 0 210 297"
       version="1.1"
       id="svg5"
       inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
       sodipodi:docname="signiture.svg"
       xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
       xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:svg="http://www.w3.org/2000/svg">
      <sodipodi:namedview
         id="namedview7"
         pagecolor="#ffffff"
         bordercolor="#000000"
         borderopacity="0.25"
         inkscape:showpageshadow="2"
         inkscape:pageopacity="0.0"
         inkscape:pagecheckerboard="0"
         inkscape:deskcolor="#d1d1d1"
         inkscape:document-units="mm"
         showgrid="false"
         inkscape:zoom="0.67150344"
         inkscape:cx="276.24579"
         inkscape:cy="612.80401"
         inkscape:window-width="1366"
         inkscape:window-height="714"
         inkscape:window-x="0"
         inkscape:window-y="26"
         inkscape:window-maximized="1"
         inkscape:current-layer="layer1" />
      <defs
         id="defs2" />
      <g
         inkscape:label="Layer 1"
         inkscape:groupmode="layer"
         id="layer1">
        <path
           style="fill:#1a1a1a;stroke-width:0.264583"
           id="path1639"
           d="m 31.809965,176.45394 c 4.616897,-6.47799 10.696953,-11.76612 16.434704,-17.21024 2.32147,-2.17247 4.657291,-4.3297 6.96441,-6.5174 4.422794,-4.19388 9.225095,-8.84396 13.510578,-13.18857 5.541907,-5.61837 10.894594,-11.41832 16.244284,-17.21827 5.878605,-6.39375 11.41064,-13.09435 17.286379,-19.49 7.9e-4,-8e-4 1.49749,-1.6475 1.86882,-1.88108 0.0452,-0.0285 0.13405,0.15652 0.0847,0.1361 -1.54823,-0.64018 -2.94082,-1.843086 -4.608189,-2.006537 -0.583813,-0.05723 -0.647374,0.978647 -0.985205,1.458217 -0.540179,0.7668 -1.099005,1.5203 -1.648507,2.28045 -6.860855,9.48903 -13.083077,19.42316 -19.157191,29.42778 -4.661252,7.98334 -9.410597,15.97956 -13.030848,24.5082 -0.47711,1.12399 -0.882362,2.27714 -1.323541,3.41571 -0.326395,1.3637 -1.130361,3.70695 -0.67786,5.23824 0.789054,2.6702 6.304534,4.14811 7.398258,4.40635 1.557801,0.3678 5.871385,-1.50104 6.999713,-1.91874 3.908473,-1.81884 7.529986,-4.15701 10.852828,-6.89715 2.576761,-2.1249 4.881462,-4.51696 7.14924,-6.95836 0.492014,-0.59089 0.99728,-1.17099 1.476039,-1.77268 1.957279,-2.45984 1.802767,-2.79309 -3.657399,-3.99345 -0.491668,-0.10809 -0.754298,0.66792 -1.108821,1.02531 -0.506468,0.51057 -0.98165,1.05124 -1.472473,1.57687 -1.689245,1.94205 -3.298714,3.97143 -4.563602,6.22201 -0.64757,1.15221 -1.326615,2.56097 -1.586227,3.88258 -0.104384,0.53138 -0.06634,1.08104 -0.09951,1.62156 0.548235,1.29974 0.384257,1.54132 1.814084,2.19424 1.961539,0.89572 3.898805,1.936 6.001126,2.4158 0.889793,0.20307 1.813189,-0.23135 2.704187,-0.42907 2.382729,-0.52873 4.278013,-1.24651 6.592228,-2.03255 1.09511,-0.40816 2.19022,-0.81632 3.28533,-1.22447 0.99805,-0.38293 1.9933,-0.77323 2.99414,-1.14877 2.07703,-0.77936 4.18823,-1.65791 6.45593,-1.5819 0.46601,0.0156 0.92175,0.14151 1.38263,0.21227 1.63634,0.46682 2.99244,1.56309 4.6815,1.88325 1.37931,0.26145 1.96422,0.14023 3.37105,0.063 2.13245,-0.19548 4.14523,-1.12557 6.30942,-1.02887 1.12305,0.0502 1.5525,0.23982 2.63057,0.54422 3.3094,1.25515 6.80164,1.84817 10.253,2.56228 2.71003,0.60416 5.3216,1.55825 7.9868,2.32444 2.16133,0.67927 4.39795,0.9199 6.65303,0.88665 1.76813,-0.15363 0.87576,-0.0592 2.67684,-0.28551 0,0 -3.80996,-2.70129 -3.80996,-2.70129 v 0 c -1.80154,0.19255 -0.90788,0.12187 -2.68074,0.21497 -2.22552,-0.0398 -4.42898,-0.31524 -6.56157,-0.98257 -2.63537,-0.76453 -5.22722,-1.69699 -7.92491,-2.22909 -3.4823,-0.6829 -6.96276,-1.38037 -10.29774,-2.62792 -1.16194,-0.27413 -1.52184,-0.43413 -2.71669,-0.42457 -2.13083,0.0171 -4.11058,0.96255 -6.23338,1.06674 -1.47927,0.0168 -1.90572,0.11961 -3.33568,-0.2385 -1.65765,-0.41514 -3.04523,-1.53183 -4.74725,-1.81127 -0.45928,-0.0296 -0.91814,-0.11095 -1.37783,-0.0887 -2.19763,0.10649 -4.22928,1.07672 -6.22944,1.88527 -4.068117,1.64451 -1.86991,0.78791 -6.186038,2.40769 -2.49709,0.7999 -4.125296,1.42675 -6.707468,1.85107 -0.919181,0.15106 -2.448687,-0.62758 -2.784081,0.24145 -0.329668,0.8542 1.550676,1.11554 1.940653,1.94395 0.381013,0.80936 -2.922603,-1.68871 -2.029542,-1.75585 -0.0083,-0.51809 -0.09355,-1.04067 -0.02498,-1.55427 0.488067,-3.65554 3.58516,-7.32509 5.984394,-9.93393 0.528973,-0.48145 1.028395,-0.99753 1.586923,-1.44436 0.37021,-0.29617 1.458388,-0.38648 1.19077,-0.77783 -0.843732,-1.23382 -2.31286,-1.90595 -3.574335,-2.70775 -0.13208,-0.0839 0.101528,0.31957 0.04887,0.46695 -0.367525,1.02861 -1.421326,2.26467 -2.001814,3.04851 -1.659633,1.9314 -2.229075,2.66959 -4.10882,4.51711 -3.94644,3.87879 -8.421206,7.14318 -13.538671,9.31269 -1.279475,0.40711 -2.524546,0.94471 -3.838424,1.22131 -1.089954,0.22945 -2.553869,-0.51216 -3.329128,0.2876 -0.510267,0.5264 1.243153,0.96033 1.433026,1.66844 0.169264,0.63127 -1.110737,-0.80628 -1.363464,-1.40901 -0.611394,-1.45811 0.07952,-3.90706 0.314783,-5.24029 0.388604,-1.15825 0.735369,-2.3314 1.165817,-3.47476 3.263683,-8.66907 7.877075,-16.76057 12.487878,-24.76152 1.173184,-1.94168 2.318864,-3.90025 3.519549,-5.82505 4.999762,-8.01507 10.379022,-15.82185 16.445362,-23.07102 0.62365,-0.7175 1.2438,-1.43807 1.87095,-2.15251 0.39448,-0.4494 1.47676,-0.8121 1.19391,-1.33895 -3.16462,-5.894501 -2.94703,-4.069508 -4.208818,-2.344166 -0.33791,0.46205 -0.690301,0.913336 -1.03545,1.370006 -5.370422,6.74587 -10.767057,13.47393 -16.35117,20.04476 -3.964133,4.57174 -5.66126,6.58851 -9.846474,11.15404 -8.358685,9.11826 -17.166833,17.82402 -26.472573,25.9772 -2.250892,1.94354 -4.476355,3.91691 -6.752674,5.8306 -1.838995,1.54603 -3.763653,2.98876 -5.591937,4.54745 -2.106631,1.79598 -3.99505,3.81215 -5.923442,5.78981 0,0 4.259194,2.54563 4.259194,2.54563 z" />
      </g>
    </svg>"""
    
    if __name__ == "__main__":
        img = image_from_svg(svg_code, 50)
        img = pattern_image_with_title(img, 300, 300, 45)
        write_png('result.png', img)
        write_jpeg('result.jpg', img, 'WHITE')
    

    Any idea how to make this work is more then welcome. Thanks in advance!

    question 
    opened by firefoxer22 3
  • Unable to get background (255, 255, 255, 0) for Pillow image

    Unable to get background (255, 255, 255, 0) for Pillow image

    Describe the bug Sir, I need to export a Pillow image with a background (255, 255, 255, 0), I use this code to initialize the Skia to try to set the background as (255, 255, 255, 0)

    with self.surface as canvas:
          color = skia.Color(255, 255, 255, 0)
          canvas.clear(color)
    

    After I draw a line on the surface and use this code to export a Pillow image

    skia_image = self.surface.makeImageSnapshot()
    alphaType=skia.AlphaType.kUnpremul_AlphaType)
    res = skia_image.convert(colorType=skia.ColorType.kRGBA_8888_ColorType,
           alphaType=skia.AlphaType.kUnpremul_AlphaType)
    return Image.fromarray(
            res
    )
    

    But the background is (0, 0, 0, 0) when get the pillow Image

    Please help! it will be greatly appreciated. Thanks.

    opened by woestler 0
  • Skia rect dashed path effect for svg

    Skia rect dashed path effect for svg

    It seems the SVG canvas does not apply any patheffects for canvas.drawRect(...)

    from IPython.core.display import SVG
    import io
    
    stream = skia.DynamicMemoryWStream()
    canvas = skia.SVGCanvas.Make((100, 100), stream)
    
    rect = skia.Rect(10, 10, 50, 50)
    paint = skia.Paint(
                AntiAlias=True,
                PathEffect=skia.DashPathEffect.Make([10.0, 5.0], 0.0),
                Style=skia.Paint.kStroke_Style,
                StrokeWidth=1,
    )
    canvas.drawRect(rect, paint)
    
    del canvas
    stream.flush()
    
    SVG(stream.detachAsData())
    

    image

    The patheffects e.g. dashedpatheffect is being applied for PNG images without issues.

    surface = skia.Surface(100, 100)
    canvas = surface.getCanvas()
    rect = skia.Rect(10, 10, 50, 50)
    paint = skia.Paint(
            AntiAlias=True,
            PathEffect=skia.DashPathEffect.Make([10.0, 5.0], 0.0),
            Style=skia.Paint.kStroke_Style,
            StrokeWidth=1,
    )
    canvas.drawRect(rect, paint)
    image = surface.makeImageSnapshot()
    
    display(image)
    

    image

    I know we can use path.addRect(...), but the output xml is very large.

    Does anyone know if it possible to add a stroke-dasharray attribute directly to a rect in the output .svg instead?

    Cheers,

    opened by peterchenadded 0
  • import skia return ImportError: DLL load failed while importing skia: The specified module could not be found.

    import skia return ImportError: DLL load failed while importing skia: The specified module could not be found.

    Describe the bug Is not a skia-delphi package issue but a miss on requirements when used in windows OSs.

    import skia return error: ImportError: DLL load failed while importing skia: The specified module could not be found.

    To Reproduce Steps to reproduce the behavior:

    1. A clean Windows 10 installation.
    2. Install Python 3.9.12 and pip install skia-python.

    Expected behavior That skia package is found and loaded.

    Desktop (please complete the following information):

    • OS: W10 (new clean installation)
    • Python: 3.9.12
    • skia-python version: 87.4

    Additional context Checking skia pyd, with "Dependency Walker", MSVCP140.DLL is not found by PYD. After downloading and installing "Microsoft Visual C++ 2015 Redistributable Update 3 RC" package the command "import skia" WORKED fine so it is a MUST to work with Python Skia on Windows environments.

    Link to download: https://www.microsoft.com/en-US/download/details.aspx?id=52685

    bug 
    opened by shineworld 0
Releases(v87.5)
  • v87.5(Nov 7, 2022)

    What's Changed

    • Fix windows install command by @jamesgk in https://github.com/kyamagu/skia-python/pull/180
    • Build wheels for Python 3.11 (fixes #182) by @lucach in https://github.com/kyamagu/skia-python/pull/183

    New Contributors

    • @jamesgk made their first contribution in https://github.com/kyamagu/skia-python/pull/180
    • @lucach made their first contribution in https://github.com/kyamagu/skia-python/pull/183

    Full Changelog: https://github.com/kyamagu/skia-python/compare/v87.4...v87.5

    Source code(tar.gz)
    Source code(zip)
  • v87.4(Jan 20, 2022)

    What's Changed

    • Python 3.10 support by @kyamagu in https://github.com/kyamagu/skia-python/pull/161
    • Build expat for macos 10.14 compatibility by @kyamagu in https://github.com/kyamagu/skia-python/pull/152
    • Update glfw window example to correctly handle HiDPI by @xjmdoo in https://github.com/kyamagu/skia-python/pull/154
    • Fix Path.getPoint (#157) by @sherlockdoyle in https://github.com/kyamagu/skia-python/pull/158
    • Fix obsolete links in README by @kyamagu in https://github.com/kyamagu/skia-python/pull/162
    • Fix isBold bug by @sherlockdoyle in https://github.com/kyamagu/skia-python/pull/166
    • Prepare for v87.4 release by @kyamagu in https://github.com/kyamagu/skia-python/pull/171

    New Contributors

    • @xjmdoo made their first contribution in https://github.com/kyamagu/skia-python/pull/154
    • @sherlockdoyle made their first contribution in https://github.com/kyamagu/skia-python/pull/158

    Full Changelog: https://github.com/kyamagu/skia-python/compare/v87.3...v87.4

    Source code(tar.gz)
    Source code(zip)
  • v87.3(Sep 6, 2021)

  • v87.2(May 24, 2021)

  • v87.1(Jan 6, 2021)

  • v87.0(Nov 24, 2020)

    • Dependent Skia version upgraded to milestone 87 (#128)
    • Implement YUVAPixmapInfo and YUVAInfo classes
    • Implement missing Image static constructors
    • Implement PathBuilder class
    • Implement missing Path static constructors
    Source code(tar.gz)
    Source code(zip)
  • v86.1(Nov 19, 2020)

    Bugfix release for skia milestone 86

    • Upgrade skia to m86 latest commit #127
    • Fix path and typeface issues #126
    • Minor build fix for mac #125
    • Add missing Path operations #124
    • Fix pybind11 2.6 API usage #123
    • Documentation fix #122
    • Add python 3.9, drop python 3.5 #121
    Source code(tar.gz)
    Source code(zip)
  • v86.0(Sep 11, 2020)

  • v85.0(Jul 10, 2020)

    Beta-release. Expect bugs.

    Changes:

    • Update skia APIs to milestone 85
    • Use semantic versioning after skia milestone
    • Small bugfix

    Known issues:

    • Missing APIs #57 #71 #72 #88
    Source code(tar.gz)
    Source code(zip)
  • v0.0.6.postfix1(Jun 30, 2020)

  • v0.0.6(Jun 26, 2020)

    Alpha-release. Expect bugs.

    Changes:

    • API change for NumPy interoperability
    • Buffer protocol improvement for various color types
    • Support __array__interface__ and tobytes for PIL.Image interoperability
    • Support with-context in Surface.getCanvas, Document, Document.beginPage, and FILEStream
    • Improve gpu API bindings
    • Add missing PDF APIs
    • Fix return value policy on context manager and iterators

    Known issues:

    • Missing APIs: #57
    Source code(tar.gz)
    Source code(zip)
  • v0.0.5(Jun 12, 2020)

    Alpha-release. Expect bugs.

    Changes:

    • Organize documentation with rtd theme
    • Upgrade skia to milestone 84 release
    • Add PDF Document and SVG API
    • Add method tests (Point, Size, Rect, RRect, Color)
    • Add Text drawing notebook
    • Fix VM build and test errors

    Known issues:

    • Missing APIs: #57
    Source code(tar.gz)
    Source code(zip)
  • v0.0.4.postfix1(May 29, 2020)

  • v0.0.4(May 29, 2020)

    Alpha-release. Expect bugs and lack of documentation.

    Changes:

    • Add method tests (Bitmap, Data, Matrix, Picture, Pixmap, Region, Vertices)
    • Add Paint and Python Image I/O notebooks
    • Fix VM build and test errors
    • Implement Codec (@Bloodb0ne)

    Known issues:

    • Missing APIs: Document and PDF
    • Missing tutorial document
    Source code(tar.gz)
    Source code(zip)
  • v0.0.3(May 15, 2020)

    Alpha-release with limited testing. Expect bugs and lack of documentation.

    Changes:

    • Implements Font, Typeface, TextBlob, TextBlobBuilder, Image, ImageInfo, Pixmap APIs
    • Bugfix pytest
    • Minor bugfixes

    Known issues:

    • Missing APIs
    • Missing tests
    • Inaccurate documentation
    Source code(tar.gz)
    Source code(zip)
  • v0.0.2(May 1, 2020)

    Alpha-release with limited testing. Expect bugs and lack of documentation.

    Changes:

    • Enums get full C++ name
    • Implements FontMgr, Path, PathEffect, Paint, ColorFilter, ImageFilter, MaskFilter, Shader

    Known issues:

    • Missing APIs
    • Missing tests
    • Inaccurate documentation
    Source code(tar.gz)
    Source code(zip)
  • v0.0.1(Apr 16, 2020)

    Initial alpha-release with limited testing. Expect bugs and lack of documentation for this release.

    Known issues:

    • Missing APIs: Less important C++ APIs are not yet available.
    • Missing tests: Only Surface, Canvas, Path get tests.
    • Inaccurate documentation: C++ document is shown without Python API translation.
    Source code(tar.gz)
    Source code(zip)
Owner
Kota Yamaguchi
Research scientist
Kota Yamaguchi
Nutrify - take a photo of food and learn about it

Nutrify - take a photo of food and learn about it Work in progress. To make this a thing, we're going to need lots of food images... Start uploading y

Daniel Bourke 93 Dec 30, 2022
A ray tracing render implemented using Taichi language.

A ray tracing render implemented using Taichi language.

Mingrui Zhang 45 Oct 23, 2022
SimpleITK is an image analysis toolkit with a large number of components supporting general filtering operations, image segmentation and registration

SimpleITK is an image analysis toolkit with a large number of components supporting general filtering operations, image segmentation and registration

672 Jan 05, 2023
A simple plugin to view APR images in napari

napari-apr-viewer A simple plugin to view APR images in napari This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-

5 Jan 24, 2022
Fast batch image resizer and rotator for JPEG and PNG images.

imgp is a command line image resizer and rotator for JPEG and PNG images.

Terminator X 921 Dec 25, 2022
Pyconvert is a python script that you can use to convert image files to another image format! (eg. PNG to ICO)

Pyconvert is a python script that you can use to convert image files to another image format! (eg. PNG to ICO)

1 Jan 16, 2022
Script that organizes the Google Takeout archive into one big chronological folder

Script that organizes the Google Takeout archive into one big chronological folder

Mateusz Soszyński 1.6k Jan 09, 2023
A warping based image translation model focusing on upper body synthesis.

Pose2Img Upper body image synthesis from skeleton(Keypoints). Sub module in the ICCV-2021 paper "Speech Drives Templates: Co-Speech Gesture Synthesis

zhiyh 15 Nov 10, 2022
Hello, this project is an example of how to generate a QR Code using python 😁

Hello, this project is an example of how to generate a QR Code using python 😁

Davi Antonaji 2 Oct 12, 2021
Short piece of code to create a rainbow gif of gradual contours from two shapefiles

rainbow-elevation-gif Short piece of code to create a rainbow gif of gradual con

Jess Roberts 6 Jan 17, 2022
display: a browser-based graphics server

display: a browser-based graphics server Installation Quick Start Usage Development A very lightweight display server for Torch. Best used as a remote

Szymon Jakubczak 205 Oct 17, 2022
Archive of the image generator stuff from my API

alex_api_archive Archive of the image generator stuff from my API FAQ Q: Why? A: Because I am removing these components from the API Q: How do I run i

AlexFlipnote 26 Nov 17, 2022
Pixel art as well as various sets for hand crafting

Pixel art as well as various sets for hand crafting

1 Nov 09, 2021
A Python package implementing various CFA (Colour Filter Array) demosaicing algorithms and related utilities.

Colour - Demosaicing A Python package implementing various CFA (Colour Filter Array) demosaicing algorithms and related utilities. It is open source a

colour-science 218 Dec 04, 2022
Seeks to remove text from an image in a convincing way.

Text-Removal This is a Computer Vision project that seeks to successfully remove text from an image by covering the text areas in a convincing way. He

6 Nov 22, 2022
A minimal python script for generating bip39 seed phrases, and corresponding Seed Signer Seed seed phrase qr code ready for offline printing.

A minimal python script for generating bip39 seed phrases, and corresponding Seed Signer Seed seed phrase qr code ready for offline printing.

CypherToad 8 Sep 12, 2022
GTK and Python based, simple multiple image editor tool

System Monitoring Center GTK3 and Python3 based, simple multiple image editor tool. Note: Development of this application is not completed yet. The ap

Hakan Dündar 1 Feb 02, 2022
🛹 Turn an SVG into an STL for stencil creation purposes

svg2stl This repository provides a script which takes as input an SVG such as this one: It outputs an STL file like this one: You can also see an inte

Max Halford 3 Dec 29, 2021
Glyphtracer is an app for converting images of letters to a font

Glyphtracer takes an image that contains pictures of several letters. It recognizes all them and lets the user tag each letter to a Unicode code point. It then converts the images to vector form and

Jussi Pakkanen 38 Dec 24, 2022
Convert the SVG code to PNG and replace the line by a call to the image in markdown

Convert the SVG code to PNG and replace the line by a call to the image in markdown

6 Sep 06, 2022