Page 1 of 1

Trim White Space From Image?

Posted: 2019-06-05T22:41:02-07:00
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

Re: Trim White Space From Image?

Posted: 2019-06-06T03:10:36-07:00
by snibgo
Many of your "white" pixels are not exactly white. Use a fuzz factor such as 5%.

Re: Trim White Space From Image?

Posted: 2019-06-06T08:01:56-07:00
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);