Giter VIP home page Giter VIP logo

Comments (6)

justvanrossum avatar justvanrossum commented on August 12, 2024

Does image() support SVG to begin with?

from drawbot.

roberto-arista avatar roberto-arista commented on August 12, 2024

I was able to draw some svgs on a canvas, so I assumed drawbot supports them

from drawbot.

justvanrossum avatar justvanrossum commented on August 12, 2024

Ah, it doesn't work on 10.15 for example. It's mostly an OS support thing.

That said the imageSize() implementation goes through some hoops to support PDF, (animated) GIF and "others". Maybe it needs some SVG handling code.

from drawbot.

typemytype avatar typemytype commented on August 12, 2024

A lots goes wrong while drawing svg as images...

but we could get the size from the nsimage object, we just have to flag _hasPixels = True with the ext .svg here

image

from drawbot.

roberto-arista avatar roberto-arista commented on August 12, 2024

my workaround for now is this:

import xml.etree.ElementTree as ET
tree = ET.parse(imagePath)
_, _, imageWidth, imageHeight = [float(i) for i in tree.getroot().attrib["viewBox"].split()]

from drawbot.

roberto-arista avatar roberto-arista commented on August 12, 2024

I understand that svg support as input format might be complicated and unreliable. I ended up converting the svg files in pdf with cairosvg and it worked fine. I'll open a pull request to add to the docs which formats are supported by the image proporties functions and the ImageObject.

from drawbot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.