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: 19
Joined: 2018-07-22T22:22:12-07:00
Authentication code: 1152

Trim White Space From Image?

Post by GlennIM » 2019-06-05T22:41:02-07:00

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: 11823
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Trim White Space From Image?

Post by snibgo » 2019-06-06T03:10:36-07:00

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: 19
Joined: 2018-07-22T22:22:12-07:00
Authentication code: 1152

Re: Trim White Space From Image?

Post by GlennIM » 2019-06-06T08:01:56-07:00

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