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 »

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 »

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 »

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 »

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 »

hi - am using Magick.net-AnyCPU and not ImageMagick component
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: SVG to TIFF conversion - Impact in Image resolution

Post by dlemstra »

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 »

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: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: SVG to TIFF conversion - Impact in Image resolution

Post by dlemstra »

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 »

dlemstra wrote:What is the value of ConfigHelper.ImageResolution?
<add key="imageResolution" value="450" />
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: SVG to TIFF conversion - Impact in Image resolution

Post by dlemstra »

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 »

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 »

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 »

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: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: SVG to TIFF conversion - Impact in Image resolution

Post 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.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: SVG to TIFF conversion - Impact in Image resolution

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