SVG to TIFF conversion - Impact in Image resolution

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
ranjith328
Posts: 28
Joined: 2016-02-01T04:44:13-07:00
Authentication code: 1151

SVG to TIFF conversion - Impact in Image resolution

Post by ranjith328 » 2016-02-01T04:49:19-07:00

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.

olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: SVG to TIFF conversion - Impact in Image resolution

Post by olear » 2016-02-01T06:06:46-07:00

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.

ranjith328
Posts: 28
Joined: 2016-02-01T04:44:13-07:00
Authentication code: 1151

Re: SVG to TIFF conversion - Impact in Image resolution

Post by ranjith328 » 2016-02-01T06:21:46-07:00

Hi.. i have already used similar steps in the code. :(

olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: SVG to TIFF conversion - Impact in Image resolution

Post by olear » 2016-02-01T06:27:27-07:00

And your ImageMagick version is built against librsvg?

ranjith328
Posts: 28
Joined: 2016-02-01T04:44:13-07:00
Authentication code: 1151

Re: SVG to TIFF conversion - Impact in Image resolution

Post by ranjith328 » 2016-02-01T07:20:13-07:00

hi - am using Magick.net-AnyCPU and not ImageMagick component

User avatar
dlemstra
Posts: 1569
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: SVG to TIFF conversion - Impact in Image resolution

Post by dlemstra » 2016-02-01T07:22:46-07:00

Can you post the code you tried so far?

p.s. Magick.NET uses librsvg.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

ranjith328
Posts: 28
Joined: 2016-02-01T04:44:13-07:00
Authentication code: 1151

Re: SVG to TIFF conversion - Impact in Image resolution

Post by ranjith328 » 2016-02-01T08:08:37-07:00

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;
}

User avatar
dlemstra
Posts: 1569
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: SVG to TIFF conversion - Impact in Image resolution

Post by dlemstra » 2016-02-01T09:33:48-07:00

What is the value of ConfigHelper.ImageResolution?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

ranjith328
Posts: 28
Joined: 2016-02-01T04:44:13-07:00
Authentication code: 1151

Re: SVG to TIFF conversion - Impact in Image resolution

Post by ranjith328 » 2016-02-01T09:35:49-07:00

dlemstra wrote:What is the value of ConfigHelper.ImageResolution?
<add key="imageResolution" value="450" />

User avatar
dlemstra
Posts: 1569
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: SVG to TIFF conversion - Impact in Image resolution

Post by dlemstra » 2016-02-01T14:04:28-07:00

Could you share an svg file that produces this odd behavior?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

ranjith328
Posts: 28
Joined: 2016-02-01T04:44:13-07:00
Authentication code: 1151

Re: SVG to TIFF conversion - Impact in Image resolution

Post by ranjith328 » 2016-02-01T18:06:18-07:00

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

ranjith328
Posts: 28
Joined: 2016-02-01T04:44:13-07:00
Authentication code: 1151

Re: SVG to TIFF conversion - Impact in Image resolution

Post by ranjith328 » 2016-02-02T02:46:34-07:00

Hi .. were you able to download the file ?

ranjith328
Posts: 28
Joined: 2016-02-01T04:44:13-07:00
Authentication code: 1151

Re: SVG to TIFF conversion - Impact in Image resolution

Post by ranjith328 » 2016-02-02T02:48:24-07:00

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 ?

User avatar
magick
Site Admin
Posts: 11063
Joined: 2003-05-31T11:32:55-07:00

Re: SVG to TIFF conversion - Impact in Image resolution

Post by magick » 2016-02-02T04:01:56-07:00

From the command-line we get:
  • convert -density 600 kx1o5sdm.svg -resize 25% -compress zip kx1o5sdm.tif
The kx1o5sdm.tif image is 3MB.

User avatar
dlemstra
Posts: 1569
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: SVG to TIFF conversion - Impact in Image resolution

Post by dlemstra » 2016-02-02T04:48:54-07:00

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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

Post Reply