Pixplicity / sharp

Scalable vector graphics for Android
Apache License 2.0
1.03k stars 117 forks source link

Transparent background issue #51

Closed dburgosp closed 4 years ago

dburgosp commented 5 years ago

Hi.

Nice library, thanks a lot :)

I am having problems when loading some SVG with transparent background, for example https://back.webel.es/v1/images/categorias/5c12552f15e4fd133439cd97.svg

The transparent background appears black on an Android device using Sharp. Any idea?

Thanks in advance.

pflammertsma commented 4 years ago

It appears that the cause of this issue is the <clipPath> tag as this is not supported by Sharp. Instead of interpreting this as a clipping path, Sharp simply renders the content. Since the enclosed rect is by default filled as black, the a 300x300 black rectangle is rendered before any other content.

There are two possible workarounds:

  1. Specify the fill opacity of the clipping path as transparent by setting fill-opacity="0" on the enclosed rect, or
  2. Remove the clipping path altogether.

Perhaps a future version will ignore clipping path altogether as I think it's a bit too ambitious to implement clipping paths as per the SVG spec.

pflammertsma commented 4 years ago

This issue is related to #19.