title: remove background(any color) from image using image magick
body: <p>Hi I am asking this with reference to this question <a href="https://stackoverflow.com/questions/40089196/fuzzy-flood-fill-in-imagemagic-php-making-a-transparent-image/">Fuzzy flood fill in ImageMagic php - making a transparent image</a></p>
  <pre><code> #!/bin/bash
  
  # Get size of original
  sz=$(convert -format &quot;%wx%h&quot; phone.png info:)
  
  # Floodfill background area with transparency
  convert phone.png -fuzz 5% -fill none -draw 'color 0,0 floodfill' ObjectOnTransparent.png
  
  # Extract alpha channel
  convert ObjectOnTransparent.png -alpha extract Alpha.png
  
  # Extract edges of alpha channel - experiment with thickness
  convert Alpha.png -edge 1 AlphaEdges.png
  
  # Get difference from background for all pixels
  convert phone.png \( +clone -fill white -colorize 100% \) -compose difference -composite Diff.png
  
  # Multiply edges with difference, so only edge pixels will have a chance of getting through to final mask
  convert AlphaEdges.png Diff.png -compose multiply -composite EdgexDiff.png
  
  # Extend Alpha by differences at edges
  convert Alpha.png EdgexDiff.png -compose add -composite ReEdgedAlpha.png
  
  # Apply new alpha to original image
  convert phone.png \( ReEdgedAlpha.png -colorspace gray \) -compose copyopacity -composite RemaskedPhone.png
  
  # Splat RemaskedPhone over red background
  convert -size $sz xc:red RemaskedPhone.png -composite Result.png
  </code></pre>
  <p>I ran these scripts and it is running accurate on images with white background and it is producing clean edges, but I want to ask if there is any way that I can remove any color background from an image like this image  <a href="https://ibb.co/BNWnNBs" rel="nofollow noreferrer">https://ibb.co/BNWnNBs</a>   from which I want to remove the black color from corners of image like this <a href="https://ibb.co/x7nD8Vb" rel="nofollow noreferrer">https://ibb.co/x7nD8Vb</a>.</p>
  <p>Any help is appreciated thanks</p>