title: ImageMagick - Remove black borders
body: <p>I have about 100 scanned pictures (.jpg), all with black borders (top/right/bottom/left), like this:</p>
  
  <p><a href="https://i.stack.imgur.com/iGEVO.jpg" rel="nofollow noreferrer">input.jpg</a></p>
  
  <p>I want to trim my picture automatically, that it is without ANY black border. </p>
  
  <p>I tried different codes, the best result I get with this code (I use Imagemagick Version 7.0.7-Q16 for Windows):</p>
  
  <pre><code>magick mogrify -bordercolor black -fuzz 20% -trim -format jpg *.jpg
  </code></pre>
  
  <p>It generates this picture:</p>
  
  <p><a href="https://i.stack.imgur.com/quccm.jpg" rel="nofollow noreferrer">result with my code</a></p>
  
  <p>Which is a good start, but as you can still see there is a rest of the black border on the top, right, bottom and left side of the image and two black areas in the sky .</p>
  
  <p>I want that the picture looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/SWfbd.jpg" rel="nofollow noreferrer">wish result</a> </p>
  
  <p>How can I do this?</p>
  
  <p>Any help or hint for my problem will be appreciated! Thanks in advance!</p>