Commit 772385a87 for imagemagick.org

commit 772385a8786d333b96f756bf2bcf8b405d52189c
Author: David Grieser <61581280+dgrieser@users.noreply.github.com>
Date:   Thu Oct 15 01:49:14 2026 +0200

    Draw SVG strokes in the internal SVG renderer again (#9031)

    Since 7.1.1-28 (fab46a462, the fix for #7097) the root graphic context
    of the internal SVG renderer sets "stroke-opacity 0". With SVG
    compliance stroke-opacity multiplies, so every stroke without an
    explicit stroke-opacity is fully transparent.

    Restore "stroke-opacity 1" and fix the black outline of #7097 in
    RenderMVGContent() instead: with SVG compliance, "opacity",
    "fill-opacity", "stroke-opacity", "fill" and "stroke" keep paint
    "none" (alpha 0) transparent. MVG without SVG compliance is unchanged.

    Fixes #9030

    Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

diff --git a/MagickCore/draw.c b/MagickCore/draw.c
index 6261b3ced..08a0da224 100644
--- a/MagickCore/draw.c
+++ b/MagickCore/draw.c
@@ -3046,7 +3046,9 @@ static MagickBooleanType RenderMVGContent(Image *image,
               }
             status&=(MagickStatusType) QueryColorCompliance(token,AllCompliance,
               &graphic_context[n]->fill,exception);
-            if (graphic_context[n]->fill_alpha != (double) OpaqueAlpha)
+            if ((graphic_context[n]->fill_alpha != (double) OpaqueAlpha) &&
+                ((graphic_context[n]->compliance != SVGCompliance) ||
+                 (graphic_context[n]->fill.alpha != (double) TransparentAlpha)))
               graphic_context[n]->fill.alpha=graphic_context[n]->fill_alpha;
             break;
           }
@@ -3070,8 +3072,9 @@ static MagickBooleanType RenderMVGContent(Image *image,
             if (graphic_context[n]->fill.alpha != (double) TransparentAlpha)
               graphic_context[n]->fill.alpha=graphic_context[n]->fill_alpha;
             else
-              graphic_context[n]->fill.alpha=(MagickRealType)
-                ClampToQuantum((double) QuantumRange*opacity);
+              if (graphic_context[n]->compliance != SVGCompliance)
+                graphic_context[n]->fill.alpha=(MagickRealType)
+                  ClampToQuantum((double) QuantumRange*opacity);
             graphic_context[n]->fill.alpha_trait=BlendPixelTrait;
             break;
           }
@@ -3326,7 +3329,15 @@ static MagickBooleanType RenderMVGContent(Image *image,
                 graphic_context[n]->fill_alpha=(double) QuantumRange*opacity;
                 graphic_context[n]->stroke_alpha=(double) QuantumRange*opacity;
               }
-            if (graphic_context[n]->fill.alpha != (double) TransparentAlpha)
+            if (graphic_context[n]->compliance == SVGCompliance)
+              {
+                if (graphic_context[n]->fill.alpha != (double) TransparentAlpha)
+                  graphic_context[n]->fill.alpha=graphic_context[n]->fill_alpha;
+                if (graphic_context[n]->stroke.alpha != (double) TransparentAlpha)
+                  graphic_context[n]->stroke.alpha=
+                    graphic_context[n]->stroke_alpha;
+              }
+            else if (graphic_context[n]->fill.alpha != (double) TransparentAlpha)
               {
                 graphic_context[n]->fill.alpha=graphic_context[n]->fill_alpha;
                 graphic_context[n]->stroke.alpha=
@@ -3808,7 +3819,9 @@ static MagickBooleanType RenderMVGContent(Image *image,
               }
             status&=(MagickStatusType) QueryColorCompliance(token,AllCompliance,
               &graphic_context[n]->stroke,exception);
-            if (graphic_context[n]->stroke_alpha != (double) OpaqueAlpha)
+            if ((graphic_context[n]->stroke_alpha != (double) OpaqueAlpha) &&
+                ((graphic_context[n]->compliance != SVGCompliance) ||
+                 (graphic_context[n]->stroke.alpha != (double) TransparentAlpha)))
               graphic_context[n]->stroke.alpha=
                 graphic_context[n]->stroke_alpha;
             break;
@@ -3944,8 +3957,9 @@ static MagickBooleanType RenderMVGContent(Image *image,
             if (graphic_context[n]->stroke.alpha != (double) TransparentAlpha)
               graphic_context[n]->stroke.alpha=graphic_context[n]->stroke_alpha;
             else
-              graphic_context[n]->stroke.alpha=(MagickRealType)
-                ClampToQuantum((double) QuantumRange*opacity);
+              if (graphic_context[n]->compliance != SVGCompliance)
+                graphic_context[n]->stroke.alpha=(MagickRealType)
+                  ClampToQuantum((double) QuantumRange*opacity);
             graphic_context[n]->stroke.alpha_trait=BlendPixelTrait;
             break;
           }
diff --git a/coders/svg.c b/coders/svg.c
index 9b84bb269..cca62b7ac 100644
--- a/coders/svg.c
+++ b/coders/svg.c
@@ -1637,7 +1637,7 @@ static void SVGStartElement(void *context,const xmlChar *name,
           (void) FormatLocaleFile(svg_info->file,"fill-opacity 1\n");
           (void) FormatLocaleFile(svg_info->file,"stroke \"none\"\n");
           (void) FormatLocaleFile(svg_info->file,"stroke-width 1\n");
-          (void) FormatLocaleFile(svg_info->file,"stroke-opacity 0\n");
+          (void) FormatLocaleFile(svg_info->file,"stroke-opacity 1\n");
           (void) FormatLocaleFile(svg_info->file,"fill-rule nonzero\n");
           break;
         }