Page 1 of 1

Trim in all borders

Posted: 2018-09-03T14:06:38-07:00
by zorrua
Hello all,

I am new here, hope I stay for a long.

I have scanned hundres of old photos, the problem is that all of them have borders I want to crop all of them. Here is an example:

Image

I use this command to delete automatically in batch mode:

Code: Select all

mogrify -fuzz 50% -trim +repage *.*
It works well:

Image

But the problem is that I execute the command 3 times to delete all margins, and I get problems with some photos.

How could select the side (left, right, top, botton) of the border I want to delete? I want to use different fuzz value in each execution.

Is there any other command I could use?

I will really appreciate your help.

Kind regards.

Re: Trim in all borders

Posted: 2018-09-03T16:22:31-07:00
by fmw42
Just repeat your command as many time as you want changing the fuzz value as desired. Best to add 1 pixel border of the correct color about the image before trimming.

But your image does not have a straight edge at the top. So you get some white at the top left, which prevents the black from being trimmed. You could shave or chop to remove some small amount before doing the next trim.

try

Code: Select all

mogrify -shave 10x10 -bordercolor gray -border 1 -fuzz 20% -trim +repage -bordercolor black -border 1 -fuzz 20% -trim +repage *