flutter_svg icon indicating copy to clipboard operation
flutter_svg copied to clipboard

Support SVG in `<image>` tag.

Open ThinkDigitalSoftware opened this issue 5 years ago • 12 comments

this error is thrown attempting to render this svg. https://img.shields.io/github/stars/felangel/bloc.svg?style=flat&logo=github&colorB=deeppink&label=stars

Code:

SvgPicture.network(
                    'https://img.shields.io/github/stars/felangel/bloc.svg?style=flat&logo=github&colorB=deeppink&label=stars');

Exception

════════ Exception caught by SVG ═══════════════════════════════════════════════════════════════════
The following _Exception was thrown resolving a single-frame picture stream:
Exception: Could not instantiate image codec.

When the exception was thrown, this was the stack: 
#0      _futurize (dart:ui/painting.dart:4338:5)
#1      instantiateImageCodec (dart:ui/painting.dart:1718:10)
#2      resolveImage.<anonymous closure> (package:flutter_svg/src/svg/parsers.dart:204:31)
#3      resolveImage (package:flutter_svg/src/svg/parsers.dart:218:23)
#4      _Elements.image (package:flutter_svg/src/svg/parser_state.dart:443:31)
...
Picture provider: NetworkPicture("https://img.shields.io/github/stars/felangel/bloc.svg?style=flat&logo=github&colorB=deeppink&label=stars", headers: null, colorFilter: null)
Picture key: NetworkPicture("https://img.shields.io/github/stars/felangel/bloc.svg?style=flat&logo=github&colorB=deeppink&label=stars", headers: null, colorFilter: null)

ThinkDigitalSoftware avatar Dec 21 '19 21:12 ThinkDigitalSoftware

This is using an <image> tag that actually has another SVG inside it.

dnfield avatar Dec 21 '19 23:12 dnfield

I thought that it was weird that the content type was image/svg. So what should I understand? That's its an SVG or that it's an Image?

ThinkDigitalSoftware avatar Dec 22 '19 00:12 ThinkDigitalSoftware

Oh, ok. So it's just something you need to support?

ThinkDigitalSoftware avatar Dec 22 '19 00:12 ThinkDigitalSoftware

Right

dnfield avatar Dec 22 '19 01:12 dnfield

Ok,got it. Thanks!

ThinkDigitalSoftware avatar Dec 22 '19 01:12 ThinkDigitalSoftware

Having issues with this url as well. https://img.shields.io/discord/649708778631200778.svg?logo=discord&color=blue

ThinkDigitalSoftware avatar Dec 28 '19 23:12 ThinkDigitalSoftware

I'm experiencing the exact symptoms in the title, albeit with a different problem. I converted svg containing png as data url with dart run vector_graphics_compiler -i, the original svg was over 1MB and it only came out to 80kB.

jeiea avatar Mar 02 '23 08:03 jeiea

I'm experiencing the exact symptoms in the title, albeit with a different problem. I converted svg containing png as data url with dart run vector_graphics_compiler -i, the original svg was over 1MB and it only came out to 80kB.

Is it rendering correctly?

SVGs generally encode image data as base64. VG just stores the binary version of the image and saves a bit of space that way. @jeiea if you can share the SVG I'd be interested in seeing it. It's possible it had lots of other "noise" that VG strips out, but that'd be a lot more than I'd expect.

dnfield avatar Mar 03 '23 05:03 dnfield

No, just picture is not shown.. https://fastupload.io/CznUYrI1JYEeT7N/file

jeiea avatar Mar 03 '23 06:03 jeiea

That site does not work for me. Can you attach it to this issue?

dnfield avatar Mar 03 '23 06:03 dnfield

.

jeiea avatar Mar 03 '23 07:03 jeiea

Vector Graphics oly supports PNG images right now. Adding JPEG wouldn't be hard.

dnfield avatar Mar 03 '23 07:03 dnfield