crccheck / raphael-svg-import-classic

Import SVG files to Raphael
MIT License
98 stars 40 forks source link

Losing Elements with Images #6

Open johnstew opened 11 years ago

johnstew commented 11 years ago

I am using the import plugin currently to import SVG that I save on to the server. I save it by just grabbing the svg in the html and write the data to a file with the svg extension. I can open the file up in all the browsers and see the svg and the images that are saved in them and whatever else. However, when I import that file to display the svg in the raphael paper I get empty objects where images should be.

Literally, last Thursday this functionality worked just fine. Now it is lost and we have no idea why. Tried updating to the newest version of the plugin but that did not help at all. Any ideas as to why this is happening and how it can be fixed?

crccheck commented 11 years ago

Hmm, I've never tried this with images. I'll make sure to add a test case with that. If it worked before and stopped I'm guessing that somehow the image src attribute is getting mangled at some point due to a subtle change in your workflow. I know a lot of the tools I use are always trying to "sanitize" my urls and end up doing more harm than good.

johnstew commented 11 years ago

Actually, I never tested this with image fills. I just realized that looking through my notes. I never tested this with different shapes that have image fills. I have tried setting up a simple implementation using a basic svg document that I created in Inkscape and embedded an image into it and tried to import it and I get a broken image link. It looks like something gets lost or skipped when you are dealing with images or objects with image fills.

It looks like the patterns get set up correctly other than the width and height are not being set. Also for the image corresponding to the pattern the href should be set to the base 64 encoding of the image but instead it is set to the ID. Below I attached an image that shows what I was looking at in chrome dev tools. Not sure if you know why this is happening but I am working on trying to fix this currently. Any help would be greatly appreciated.

importdebug

johnstew commented 11 years ago

Could really use some help with trying to get your code to work for images. I have stepped through this several times and it looks like you just do not handle these at all. Any chance you can take a look at it?

crccheck commented 11 years ago

I'm working on adding image support. I got it working in 722afe6. What you're asking for is pretty advanced stuff that I don't think gets used very often. I use SVG to avoid having to use images. Getting better text rendering and gradient support is a higher priority for me.

johnstew commented 11 years ago

I tested this and it did not work. Did you have a test case that did work?

crccheck commented 11 years ago

It would help if I could see an example of the original SVG.

johnstew commented 11 years ago

http://pastebin.com/01XuWBCi Here is the original SVG it has an rectangle with a fill that is a JPG.