Comments (13)
Thanks for the sample file. I have a preliminary patch available here:
master...claudep:issue93
However, the image is reversed in the document. @deeplook I already struggled with shapes reversed in past patches, do you know what's wrong with coordinates?
from svglib.
Thanks for investigating. Let's focus on bitmap formats with this ticket.
from svglib.
To be sure, there is nothing wrong with the embedded source PNG files; I even went into pdb, created a canvas and added the PDFImage object (as generated by svglib) to it and then saved as PDF. Looks fine. So it is definitely doable. But for some reason svglib does not do it...?
from svglib.
Thanks for your report! I don't have a lot of time nowadays to look into this. But I'd suggest you look into the test suite for something similar and/or create a similar case with a sample PNG, either a non-copyrighted one or one you create dynamically using https://pypi.python.org/pypi/pypng.
from svglib.
Is this related to #94, maybe?
from svglib.
@petri it would be nice to have an example file at hand.
from svglib.
I am quite sure this is not related to #94. To be absolutely sure, I will try the code on Python < 3.6 when I have time.
from svglib.
+1 embedded png images don't seem to show up on both Python 3.5.4 and 3.6.2
from svglib.
Can anybody please provide reproducible code? Thanks! I'll add something around these lines in a submitting bug reports section in the README, soon...
from svglib.
(TL;DR see the link for example file)
The issue is easy enough to reproduce and there is no question about it being valid, imho. The fact that svglib warns "Adding box instead of image." regardless of what the image type is (PNG or other) suggests to me this is a known issue. Or if not, what does that warning mean if not that???
A proper test would have to check the internals of the resulting PDF to somehow detect whether the PNG is there. I don't have time to learn how to do that, just for a single test case that I have no certainty will result in the issue getting fixed.
Having said that, here's a svg with PNG inside that can be used to confirm the issue (zipped because github does not support svg uploads): png_in_svg.zip. The PNG is the wikipedia logo so the file can be used in svglib tests.
I tried converting the unzipped svg and got the above-mentioned error.
from svglib.
To check the PDF, I am pretty sure pdfrw can do the trick: https://pypi.python.org/pypi/pdfrw . That would have to be added to the setup.py in a tests_require part.
from svglib.
I'll look into this shortly. Sorry, it takes so long!
@claudep Without looking any further (not sure if that's the reason for what you see "reversed"), PDF has a "mathematically correct" coordinate system (y-axis pointing up), while bitmaps (usually) and web pages (definitely) use any y-axis pointing down.
from svglib.
@claudep I've finally looked at your patch. Have run it only on the provided Wikipedia logo. Looks ok, but I confirm the image gets flipped vertically. The effect disappears when adding an transform="translate(0, 841.89) scale(1, -1)"
attribute to the image
element, where 841.89
is the height of the svg.viewBox
attribute. I have to play more with it, though...
Also, the SVG specs say, a renderer should implement at least PNG, JPEG and SVG as image formats, so SVG might be the funniest of these three left to support.
from svglib.
Related Issues (20)
- convert to pdf and png files is incorrect HOT 5
- wrong width and height attributes of drawing obj HOT 1
- Implementation error in rendering of paths with shorthand command for quadratic Bézier curves HOT 5
- Transform on clipPath does not work HOT 2
- Error when svg file contains references to font with space in its name HOT 1
- Error on install svglib HOT 2
- Reportlab 4.0.0 added dependency to pycairo HOT 3
- Error ByteIO HOT 3
- svglib fails to render properly HOT 12
- CI failure because of missing cairo HOT 9
- Using root log instead of logger HOT 3
- Units px and pt are wrong HOT 5
- Embedding SVG fonts in PDF/rlg HOT 5
- Add font size test case to test suite
- Rename default branch to main HOT 2
- Add more example and pip install commands to README.md HOT 4
- svglib doesn't remove temporary files properly? HOT 5
- Problems with embedded image sizes HOT 4
- svglib ignores <switch> nodes HOT 4
- Please share wheel file on pypi HOT 5
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 svglib.