Trim White Space From Image?

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
GlennIM
Posts: 23
Joined: 2018-07-23T05:22:12+00:00
Authentication code: 1152

Trim White Space From Image?

Post by GlennIM »

I'm trying to remove "white space" from images using the Trim() function but doesn't seem to work. Here is my code and the sourceImgTrimmed. What is wrong?

Code: Select all

string sourceImg = @"D:\\large_1683_EK08BK_Open_WEB.jpg";
string sourceImgTrimmed = @"D:\\large_1683_EK08BK_Open_Trimmed.jpg";
using (MagickImage image = new MagickImage(sourceImg))
{
     image.Trim();
     image.RePage();
     image.Write(sourceImgTrimmed);
 }
Image
snibgo
Posts: 12159
Joined: 2010-01-24T06:01:33+00:00
Authentication code: 1151
Location: England, UK

Re: Trim White Space From Image?

Post by snibgo »

Many of your "white" pixels are not exactly white. Use a fuzz factor such as 5%.
snibgo's IM pages: im.snibgo.com
GlennIM
Posts: 23
Joined: 2018-07-23T05:22:12+00:00
Authentication code: 1152

Re: Trim White Space From Image?

Post by GlennIM »

I added this line to the code below and it worked! Is that the correct code to use?

Code: Select all

 image.ColorFuzz = new Percentage(5);
Post Reply