SwitchbladeBot / invidget

SVG invite widgets that look just like the ones on the Discord client!
http://invidget.switchblade.xyz/
MIT License
116 stars 23 forks source link

[WIP] Accepting "format" as a query parameter #42

Open jaxxibae opened 3 years ago

jaxxibae commented 3 years ago

When ?format=<png|svg> is present, it'll automatically convert the image to one of the two formats. If not specified, will return a SVG image.

jaxxibae commented 3 years ago

Known Bug: images using ?format=png aren't rendering the server icon.

image

jaxxibae commented 3 years ago

@pedrofracassi help

pedrofracassi commented 3 years ago

How are we placing the icon in the image? Does this problem have something to do with sharp not being able to fetch the icon? Do we use base64?

jaxxibae commented 3 years ago

I think sharp isn't converting that <image> tag that's embedded in the SVG variant, we'd have to figure it out.

pedrofracassi commented 3 years ago

Maybe try this? https://stackoverflow.com/questions/58408753/svg-as-svgs-image-tag-not-working-while-using-with-sharp

Galaxy-Coding commented 3 years ago

Any updates on this PR? Maybe the make an issue in the sharp Github.

jaxxibae commented 3 years ago

No need to send them an issue, I just haven't got the time yet to pick this back up, I'll probably pick it up today.

EDIT: Thanks @pedrofracassi for the suggestion, I'll test it when I can.

jaxxibae commented 3 years ago

Also @almeidx when format isn't specified, should it default to SVG?

almeidx commented 3 years ago

Also @almeidx when format isn't specified, should it default to SVG?

To avoid breaking changes to the API, yes

jaxxibae commented 3 years ago

@pedrofracassi Your suggestion didn't work. I wasn't able to convert the jpeg/gif file which is our guild icon inside the SVG, w/o using other libs, and I don't want to add more dependencies to this project.

ghost commented 1 year ago

You guys could always use ReSVG v2 added the ability to render images from external links

ghost commented 1 year ago

Tested ReSVG and it did work

Vendicated commented 3 months ago

Known Bug: images using ?format=png aren't rendering the server icon.

image

mostly likely due to https://github.com/SwitchbladeBot/invidget/pull/82