Page 1 of 1

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

Posted: 2017-03-09T02:04:39-07:00
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?

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

Posted: 2017-03-09T02:53:22-07:00
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.

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

Posted: 2017-03-09T03:48:25-07:00
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

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

Posted: 2017-03-09T03:53:22-07:00
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.)

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

Posted: 2017-03-09T04:05:55-07:00
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)
            {

            }