Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collapseGroups causes clip-path on images to be incorrect #101

Closed
flexpaper opened this issue Feb 16, 2013 · 6 comments
Closed

collapseGroups causes clip-path on images to be incorrect #101

flexpaper opened this issue Feb 16, 2013 · 6 comments
Assignees
Labels

Comments

@flexpaper
Copy link

Firstly, I just wanted to congratulate you on a great project! I have done some initial testing and it looks like you've done some great progress already!

I have found a bug related to clip-path and how collapseGroups is working.
Original:
<clipPath id="clip2">
<path d="M 0 0 L 0 670.671875 L 759.160156 832.039062 L 765.355469 802.894531 L 765.355469 0 Z "/>
</clipPath>
<image id="image5" width="1305" height="1411" xlink:href="data:image/ ...." />

<g clip-path="url(#clip2)" clip-rule="nonzero">
<use xlink:href="#image5" transform="matrix(0.703976,0.149635,-0.149676,0.70417,51.664047,-356.818891)"/>
</g>

Result with collapseGroups active:
<clipPath id="b"><path d="M0 0v670.672l759.16 161.367 6.195-29.145v-802.895z"/></clipPath><image id="c" width="1305" height="1411" xlink:href="data:image/...: />

This causes images to be incorrectly clipped as in the screenshot attached
Screen Shot 2013-02-17 at 8 41 53 AM

@flexpaper
Copy link
Author

grab the original SVG from here:

https://dl.dropbox.com/u/13295266/Monash_Magazine_1.svg

@deepsweet
Copy link
Member

ok, i got it :)
thank you, I'll try to fix it in the minor version next week.

@ghost ghost assigned deepsweet Feb 16, 2013
@deepsweet
Copy link
Member

the problem is a bit ambiguous because clip-path property is not inheritable, so in our case <g clip-path="..."><use .../></g> doesn't make any sense.

i think that i should to correct removeUnknownsAndDefaults plugin to strip out such cases before collapseGroups will try to move the group's attributes to the content element.

@flexpaper
Copy link
Author

sounds like a good idea

@flexpaper
Copy link
Author

By the way; this SVG was created using pdftocairo (poppler utility)

@andymerskin
Copy link

I am still having issues with this happening on a very simple file with a clipped image. Not exactly sure what is happening here, but after using SVGO, the image no longer appears (probably because the clip-path isn't clipping at the right coordinates or something.

With collapseGroups enabled, the clip-path is added directly to the <image> element. Simply wrapping the <image> with a Group and adding the clip-path back to the group makes it appear correctly without modifying the clip-path definition.

Example SVGs
Original
Optimized
Optimized (collapseGroups disabled) <-- appears correctly

Does this have something to do with relative clip-path positioning?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants