Comments (4)
Yes, the size is currently truncated.
It seems obvious that rounding would be a perfect idea … but it’s not 😄.
If your SVG’s size is 10.5px, with a 10.5px white square for the background, you want to get a white PNG, and not semi-transparent pixels on the right and the bottom. So, unfortunately, rounding the surface size is not perfect in all cases.
What if we add a scale factor of 11/10.5 before rendering? That would avoid the transparent pixels (if floating point arithmetic gods love you), but we would lose pixel alignment and get blurry rendering even for horizontal and vertical lines. So, even rounding + scaling is not perfect.
So… I’m not sure about what to do here.
Even my image viewer is "broken" with this SVG file 😢
Half pixels are devil.
from cairosvg.
I think it would be easiest(?) to just provide options that allow the user to define what behavior they want, i.e. specify the rounding and/or specify a border to grow the rendering surface. That way the user has some tools to manage the conversion and you don't break the existing functionality.
from cairosvg.
Let’s round values. It’s not perfect, but nobody will ever complain. 😄
from cairosvg.
Let’s round values. It’s not perfect, but nobody will ever complain. 😄
Except tests, of course…
from cairosvg.
Related Issues (20)
- `text` property `shape-inside` not respected HOT 1
- Convert to WebP HOT 1
- Add rlPyCairo to requirements.txt HOT 1
- Stroke Width is not taken into account for final height / width HOT 3
- OSE Error cairo-2 not found HOT 6
- Conversion of multiple files halted with error HOT 2
- SVG to PDF render improper PNG position HOT 1
- OSError: no library called "cairo-2" was found HOT 1
- RecursionError: maximum recursion depth exceeded in comparison HOT 1
- svg2pdf incorrect width and height output - HOT 1
- Feature request: support style='background_color:xxxx' in the <svg> object
- Add support for blend modes
- Missing linked images and text HOT 6
- svg2png the stroke attribute causes display anomalies. HOT 1
- Fail of image path resolution in a defs/use context HOT 1
- SVG path parse error
- ValueError: could not convert string to float: 'null' HOT 1
- ValueError: could not convert string to float: '' HOT 1
- Can't convert svg to pdf HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cairosvg.