diff --git a/src/SingleProject/Resizetizer/src/SkiaSharpSvgTools.cs b/src/SingleProject/Resizetizer/src/SkiaSharpSvgTools.cs index ea2bed844b0b..eb84b186321c 100644 --- a/src/SingleProject/Resizetizer/src/SkiaSharpSvgTools.cs +++ b/src/SingleProject/Resizetizer/src/SkiaSharpSvgTools.cs @@ -35,6 +35,11 @@ public override SKSize GetOriginalSize() => public override void DrawUnscaled(SKCanvas canvas, float scale) { + var size = GetOriginalSize(); + if (size.IsEmpty) + { + throw new InvalidOperationException($"Cannot draw SVG file '{Filename}'. The SVG has no size. Ensure the SVG includes a viewBox attribute or both width and height attributes with valid dimensions."); + } if (scale >= 1) { // draw using default scaling @@ -42,9 +47,6 @@ public override void DrawUnscaled(SKCanvas canvas, float scale) } else { - // draw using raster downscaling - var size = GetOriginalSize(); - // vector scaling has rounding issues, so first draw as intended var info = new SKImageInfo((int)size.Width, (int)size.Height); using var surface = SKSurface.Create(info);