3

When trimming images with Magick.net (to remove white areas around the main object of the image) and they've got a clipping path, then the path is not synchronized with the new proportions of the image.

Looking at the image with the path selected, in Photoshop, after a trim has been performed

Is there a way to handle this using Magick.Net, so that the path still trace the objects that it did before trimming?

(Magick.net uses ImageMagick for its image processing, so if anyone knows how to do it in ImageMagick, perhaps it's easily "translated" into MagickNet.)

Adding some more information: Here is a link to a simple image with a clipping path in it (I just made a few strokes in Photoshop and made it into a path): Zip archive with sample files in different formats, containing paths.

And below you will find a piece of code that uses Magic.Net for trimming that image, with the resulting displacement of the path.

// Put a reference to Magick.net-Q8-AnyCPU using "nuget"

using ImageMagick;
using System;
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = @"C:\Temp\Path-test-jpg.jpg";
            MagickNET.SetGhostscriptDirectory(@"C:\Temp\ConsoleApplication2\bin\Debug");
            using (MagickImage image = new MagickImage(path))
            {
                // DPI
                Console.WriteLine(image.Density);
                //// Trim
                image.Trim();

                image.Quality = 99;

                image.Write(@"C:\Temp\test-out.jpg");
            }
        }
    }
}

enter image description here

Andreas Jansson
  • 830
  • 1
  • 9
  • 21

0 Answers0