Page 1 of 3

SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-01T04:49:19-07:00
by ranjith328
Hi There,

I am using Magick.Net to convert SVG files (Created using adobe illustrator) to Multipage TIFF. (i will be editing some text in svg using my solution)
Unfortunately eventhough i has created the SVG (vector) texts, after conversion to tiff files, the resolution is degraded and the quality is reduced.
Is there any way to keep the same resolution of vector after conversion.

Can you please help.

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-01T06:06:46-07:00
by olear
In Magick++ I use :

Code: Select all

    image.resolutionUnits(Magick::PixelsPerInchResolution);
    image.density(Magick::Geometry(dpi,dpi));
To set the desired output of the SVG, You can probably find something similar in Magick.NET.

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-01T06:21:46-07:00
by ranjith328
Hi.. i have already used similar steps in the code. :(

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-01T06:27:27-07:00
by olear
And your ImageMagick version is built against librsvg?

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-01T07:20:13-07:00
by ranjith328
hi - am using Magick.net-AnyCPU and not ImageMagick component

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-01T07:22:46-07:00
by dlemstra
Can you post the code you tried so far?

p.s. Magick.NET uses librsvg.

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-01T08:08:37-07:00
by ranjith328
Hi.. below is the piece of code that i used to convert SVG to TIFF / PDF
I tried output format with both TIFF and PDF

/// <summary>
/// Convert SVG file to file of format specified
/// </summary>
/// <param name="svgFilePath">Path to input svg file</param>
/// <param name="outFormat">Output graphic format specification</param>
internal static MagickImage ConvertSvg(string svgFilePath, MagickFormat outFormat)
{
var mgKimage = new MagickImage();

var mrs = new MagickReadSettings
{
Format = MagickFormat.Svg,
ColorSpace = ColorSpace.Transparent,
Density = new MagickGeometry(ConfigHelper.ImageResolution)
};

mgKimage.Read(svgFilePath, mrs);

mgKimage.ResolutionUnits = Resolution.PixelsPerInch;
mgKimage.Format = outFormat;
mgKimage.BackgroundColor = new MagickColor(Color.Transparent);

return mgKimage;
}

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-01T09:33:48-07:00
by dlemstra
What is the value of ConfigHelper.ImageResolution?

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-01T09:35:49-07:00
by ranjith328
dlemstra wrote:What is the value of ConfigHelper.ImageResolution?
<add key="imageResolution" value="450" />

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-01T14:04:28-07:00
by dlemstra
Could you share an svg file that produces this odd behavior?

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-01T18:06:18-07:00
by ranjith328
dlemstra wrote:Could you share an svg file that produces this odd behavior?
i am unable to attach the file. instead i have uploaded the file to

http://speedy.sh/pCmCe/kx1o5sdm.svg

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-02T02:46:34-07:00
by ranjith328
Hi .. were you able to download the file ?

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-02T02:48:24-07:00
by ranjith328
ranjith328 wrote:Hi .. were you able to download the file ?
also another point which we noticed is that, after conversion from SVG to tiff with dpi set as 450, the file size is growing to more that 120MB.
is that expected or an odd behavior ?

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-02T04:01:56-07:00
by magick
From the command-line we get:
  • convert -density 600 kx1o5sdm.svg -resize 25% -compress zip kx1o5sdm.tif
The kx1o5sdm.tif image is 3MB.

Re: SVG to TIFF conversion - Impact in Image resolution

Posted: 2016-02-02T04:48:54-07:00
by dlemstra
And with the following code I get a 19MB file with Magick.NET that is perfectly readable:

Code: Select all

using (var mgKimage = new MagickImage())
{
  var mrs = new MagickReadSettings
  {
    Format = MagickFormat.Svg,
    ColorSpace = ColorSpace.Transparent,
    Density = new PointD(450)
  };

  mgKimage.Read(@"C:\kx1o5sdm.svg", mrs);

  mgKimage.ResolutionUnits = Resolution.PixelsPerInch;
  mgKimage.Format = MagickFormat.Tiff;
  mgKimage.BackgroundColor = new MagickColor(Color.Transparent);
  mgKimage.Write(@"C:\test.Tiff");
}
Are you using the latest version of Magick.NET? It looks like you are using an older version. The most recent version uses a PointD for the density.