0

So I am receiving input of Icons Url, and want to display them on AdaptiveCards in Microsoft Teams

My proplem is when I receive an Icon Url with svg extension, it's not rendered on the adaptive card and replaces it with undefined

I've tried doing this :

            byte[] imageBytes;
            using (var webClient = new WebClient())
            {
                imageBytes = webClient.DownloadData(appSuggestion.IconUri.AbsoluteUri);
            }
            this.Body.Add(new AdaptiveColumnSet
                {
                    Columns = new List<AdaptiveColumn>
                    {
                        new AdaptiveColumn
                        {
                            Items =
                            {
                                new AdaptiveImage
                                {
                                    Url = new System.Uri("data:image/svg+xml;base64,"+Convert.ToBase64String(imageBytes)),
                                    PixelWidth = 45,
                                    PixelHeight = 45,
                                },
                            },
                            Width = AdaptiveColumnWidth.Auto,
                        },
            }
    }

but It still no working .. Any ideas, how can I convert svg to png without saving the image on local path?

Rex
  • 147
  • 3
  • 11
  • Does this answer your question? [Converting SVG to PNG using C#](https://stackoverflow.com/questions/58910/converting-svg-to-png-using-c-sharp) – Tomáš Filip Jun 29 '20 at 12:51
  • @Tofik No, the solutions are expecting the image to be saved locally, or it the png version will be saved locally – Rex Jun 29 '20 at 12:54
  • Especially the second answer does not require that. You get bitmap / MemoryStream – Tomáš Filip Jun 29 '20 at 12:56
  • You must consider if you can paste SVG directly to web page instead convert it to PNG, and than insert as `data:image/svg+xml;base64,` – Leszek Mazur Jun 29 '20 at 13:10
  • @LeszekMazur Didn't understand you very well, the svg link I get works fine in web page .. – Rex Jun 29 '20 at 13:20
  • @Tofik and how can I use the bitmap as a link in adaptivecards? – Rex Jun 29 '20 at 13:25
  • Does your graphic card support SVG? You can only display the graphics modes the card and driver supports. You may have an old driver that needs updating that doesn't support the SVG mode in the file. You can open the SVG file with notepad to see the ASCII header which will indicate the graphic mode. – jdweng Jun 29 '20 at 13:55
  • @jdweng yes, it does support – Rex Jun 29 '20 at 13:57
  • Then there is something wrong with the driver installation. The driver installer for the graphic card should add the icon type to the window operating system. Some how the file type is missing. – jdweng Jun 29 '20 at 14:02
  • You can from cmd.exe get a list of all file extensions by type following >assoc >c:\temp\assoc.txt – jdweng Jun 29 '20 at 14:12
  • When SVG first came out some graphics cards did not support all the modes So opening the SVG in Notepad would give the SVG mode. Usually the fix was to update the driver where new driver supported the missing modes. Other cases people saved a graphic file with wrong extension. So opening file with Notepad would also help determine if the file has correct extension. – jdweng Jun 29 '20 at 14:20

1 Answers1

0

Currently teams does not support .SVG in cards. Could you please check this docs here?

Nikitha-MSFT
  • 577
  • 1
  • 3
  • 6
  • Thanks, I've just searched it online. I guess I have to find a way to convert the svg to png – Rex Jun 30 '20 at 05:07