EPS to PNG conversion - Different than ImageMagick CLI

Jul 8, 2014 at 11:24 AM
Hi,

I am using Magick.NET 6.0.0.0 to convert eps files to png format. There is difference in converted image and image that is generated using ImageMagick CLI.

I am doing following operations on image
  1. Scaling
  2. Set density
  3. Trimming
First two operations are done to same image instance while third operation is carried out on separate instance.

Please see the generated images uploaded https://plus.google.com/u/1/photos/108639021834884343360/albums/6033647140539995985

Also sharing the input eps image
https://drive.google.com/file/d/0B4j2swjUHvB2WkZhV3pWU1VwTms/edit?usp=sharing

Please suggest.
Coordinator
Jul 8, 2014 at 12:09 PM
Edited Jul 9, 2014 at 6:53 AM
You are reporting a incorrect version. Magick.NET 6.0.0.0 is the 'assembly version' that has been the same since the first release. You can get the version with 'MagickNET.Version'.

What is your command line command and what is your C# code?
Jul 9, 2014 at 6:45 AM
Actually I am not able to trace download link for release, so I mentioned Assembly version, assembly file version is "6.8.5.4". API I am using has MagickNET.Version property.

I should have mentioned commands in earlier post, sorry for that

convert -geometry 1024x768 -density 1024 "Sample.eps" -trim "L.png"

Following are statements I am executing, I have simplified it for you and applying density, trimming operation are configuration driven.
            using (MagickImage img = new MagickImage(sourcepath))
            {
                img.ImageType = type;
                if (sizeInRatio)
                {
                    img.Scale(new Percentage(width.Value), new Percentage(height.Value));
                }
                else
                {
                    img.Scale(width.Value, height.Value);
                }
                img.Write(destinationpath);
            }
            using (MagickImage img = new MagickImage(destinationpath))
            {                
                if (density > 0)
                {
                    img.Density = new MagickGeometry(density, 0);
                }
               if (trim)
               {
                     img.Trim();
               }
               img.Write(destinationpath);
            }
Coordinator
Jul 9, 2014 at 11:02 AM
I would recommend you to upgrade to the latest version of Magick.NET. Your command translates to this:
using (MagickImage image = new MagickImage())
{
  MagickReadSettings settings = new MagickReadSettings();
  settings.Density = new MagickGeometry(1024); // -density 1024

  image.Read("Sample.eps", settings); // "Sample.eps"
  image.Resize(1024, 768); // -geometry 1024x768
  image.Trim(); // -trim
  image.Write("L.png"); // "L.png" 
}
Jul 14, 2014 at 10:03 AM
Thanks a ton.

Snippet generated correct image.

Have a good day ahead.