Search code examples
c#microsoft-teamsadaptive-cards

Convert svg url to png url


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?


Solution

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