You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have verified that I am using the latest version of Magick.NET
I have searched open and closed issues to ensure it has not already been reported
Description
I'm seeing a weird results (png is getting clipped) when converting a particular SVG into PNG using Magick.NET (same issue using imagemagick from the console). The PNG is converted properly if a viewBox is defined in the SVG.
Steps to Reproduce
Run the following code:
usingSystem.IO;usingSystem.Net.Http;usingSystem.Text;usingSystem.Threading.Tasks;usingImageMagick;namespaceConsoleApp7{classProgram{staticasyncTaskMain(){varhttpClient=newHttpClient();// #1 - No ViewBox but png converted correctlyvarsvg1=awaithttpClient.GetStringAsync("https://img.vggcdn.net/svgv2/156660.svg?v=47");ConvertSvgToPng(svg1,"./1-svg-no-viewbox-but-converted-correctly.png");// #2 - No ViewBox but png converted incorrectlyvarsvg2=awaithttpClient.GetStringAsync("https://img.vggcdn.net/svgv2/195035.svg?v=14");ConvertSvgToPng(svg2,"./2-svg-no-viewbox-but-converted-incorrectly.png");// #3 - ViewBox and png converted correctlyvarsvg3=svg2.Replace("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">","<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"281 11 962 995\">");ConvertSvgToPng(svg3,"./3-svg-viewbox-and-converted-correctly.png");}staticvoidConvertSvgToPng(stringsvg,stringfileName){varsettings=newMagickReadSettings{Format=MagickFormat.Svg,BackgroundColor=MagickColors.Transparent};using(varimage=newMagickImage(Encoding.UTF8.GetBytes(svg),settings)){image.Write(newFileInfo(fileName),MagickFormat.Png32);}}}}
System Configuration
Magick.NET version: Magick.NET-Q16-AnyCPU 7.23.4
Environment (Operating system, version and so on): Windows 10
Additional information:
The text was updated successfully, but these errors were encountered:
It turns out that both ImageMagick and the librsvg library are using a viewbox where part of the image is outside the viewbox. This will probably not be easy to fix. I would advise you to add the viewbox when it is missing. Will leave this open in case someone wants to spend time investigating why this is happening.
Prerequisites
Description
I'm seeing a weird results (png is getting clipped) when converting a particular SVG into PNG using Magick.NET (same issue using imagemagick from the console). The PNG is converted properly if a
viewBox
is defined in the SVG.Steps to Reproduce
Run the following code:
System Configuration
The text was updated successfully, but these errors were encountered: