dominant-baseline in SVG text element not working when convert svg to image (png,jpg,...)

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
amir123
Posts: 9
Joined: 2017-03-08T04:39:11-07:00
Authentication code: 1151

dominant-baseline in SVG text element not working when convert svg to image (png,jpg,...)

Post by amir123 »

Hi Magick Developers Team

I create svg file with one text element and set style to dominant-baseline:hanging

When I browse svg file in web browser, that's right and all things is good

But when I convert svg to image such as png, then text element not at own position!

svg code:

Code: Select all

<svg width="500" height="300" xmlns="http://www.w3.org/2000/svg">
  <g transform="scale(1)">
    <text style="dominant-baseline:hanging; font-family:'Tahoma';fill:rgb(51, 51, 51);direction:ltr;font-size:50pt;font-weight:400;font-style:normal;text-decoration:none;" x="263" y="179" transform="rotate(0 263 179)">Item 1234</text>
  </g>
</svg>
Text String is upper than real position!

Image

why?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: dominant-baseline in SVG text element not working when convert svg to image (png,jpg,...)

Post by snibgo »

Inkscape gives the same result as IM using Inkscape as a delegate, and similar to your "bad" result. If this is wrong, the fault is in Inkscape.
snibgo's IM pages: im.snibgo.com
amir123
Posts: 9
Joined: 2017-03-08T04:39:11-07:00
Authentication code: 1151

Re: dominant-baseline in SVG text element not working when convert svg to image (png,jpg,...)

Post by amir123 »

snibgo wrote: 2017-03-09T02:53:22-07:00 Inkscape gives the same result as IM using Inkscape as a delegate, and similar to your "bad" result. If this is wrong, the fault is in Inkscape.
I convert with magick and inkscape

magick result is bad but inkscape is correct position and it is good
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: dominant-baseline in SVG text element not working when convert svg to image (png,jpg,...)

Post by snibgo »

I used IM v6.9.5-3 and Inscape v0.91.

Did your convert use Inkscape as the delegate? (Using "-verbose" will tell you.)
snibgo's IM pages: im.snibgo.com
amir123
Posts: 9
Joined: 2017-03-08T04:39:11-07:00
Authentication code: 1151

Re: dominant-baseline in SVG text element not working when convert svg to image (png,jpg,...)

Post by amir123 »

snibgo wrote: 2017-03-09T03:53:22-07:00 I used IM v6.9.5-3 and Inscape v0.91.
I use
1. Magick.NET-Q16-AnyCPU version:7.0.0.0
2. inkscape v0.92.0

snibgo wrote: 2017-03-09T03:53:22-07:00 Did your convert use Inkscape as the delegate? (Using "-verbose" will tell you.)
what's this?

magick code:

Code: Select all

            try
            {

                ImageMagick.MagickImage image = new ImageMagick.MagickImage(@"c:\1.svg");
                image.Format = ImageMagick.MagickFormat.Png;
                image.Settings.TextAntiAlias = true;
                ImageMagick.MagickColor mc = new ImageMagick.MagickColor(Color.Transparent);
                image.Transparent(mc);
                image.Write(@"c:\Magick.png");
            }
            catch (Exception ex)
            {

            }

inkscape code:

Code: Select all

            try
            {
                string inkscapeArgs =
                 "-f " + "c:\\1.svg" + " -e \"" +
                 "c:\\ink.png"
                 ;

                Process inkscape = Process.Start(
                  new ProcessStartInfo(
                   "C:\\program files\\inkscape\\inkscape.exe",
                   inkscapeArgs));

            }

            catch (Exception ex)
            {

            }
Post Reply