Code Monkey home page Code Monkey logo

Comments (13)

claudep avatar claudep commented on July 17, 2024 1

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.

claudep avatar claudep commented on July 17, 2024 1

Thanks for investigating. Let's focus on bitmap formats with this ticket.

from svglib.

petri avatar petri commented on July 17, 2024

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.

deeplook avatar deeplook commented on July 17, 2024

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.

deeplook avatar deeplook commented on July 17, 2024

Is this related to #94, maybe?

from svglib.

claudep avatar claudep commented on July 17, 2024

@petri it would be nice to have an example file at hand.

from svglib.

petri avatar petri commented on July 17, 2024

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.

oldaccountarchived avatar oldaccountarchived commented on July 17, 2024

+1 embedded png images don't seem to show up on both Python 3.5.4 and 3.6.2

from svglib.

deeplook avatar deeplook commented on July 17, 2024

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.

petri avatar petri commented on July 17, 2024

(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.

petri avatar petri commented on July 17, 2024

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.

deeplook avatar deeplook commented on July 17, 2024

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.

deeplook avatar deeplook commented on July 17, 2024

@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)

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.