This project has moved. For the latest updates, please go here.

EPS to PNG conversion - Different than ImageMagick CLI

Jul 8, 2014 at 11:24 AM

I am using Magick.NET 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

Also sharing the input eps image

Please suggest.
Jul 8, 2014 at 12:09 PM
Edited Jul 9, 2014 at 6:53 AM
You are reporting a incorrect version. Magick.NET 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 "". 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));
                    img.Scale(width.Value, height.Value);
            using (MagickImage img = new MagickImage(destinationpath))
                if (density > 0)
                    img.Density = new MagickGeometry(density, 0);
               if (trim)
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.