title: imagemagick trim the bottom from transparent PNG
body: <p>I am attempting to write an imagemagick command to trim the transparent pixels from the bottom of a transparent PNG. <a href="http://www.fmwconcepts.com/imagemagick/tidbits/image.php#trim_2sides" rel="nofollow noreferrer">I found these commands</a> and modified them to take off just the bottom. However the output is not as expected.</p>
  <p>With some trial and error I've identified that the command appears to be generating an image of a minimum height. If the design is too high it leaves transparent pixels underneath. But nothing jumps out at me as being the element of the command that causes that?</p>
  <p>I've included my 3 files that I trimmed and the 3 results that the following command(s)
  generates:</p>
  <pre><code>convert \( ORIGINAL.png -bordercolor none -border 1x0 \) -size 1x1 xc:black -gravity west -composite -size 1x1 xc:black -gravity east -composite -size 1x1 xc:black -gravity north -composite -fuzz 10% -trim +repage -bordercolor white -shave 1x0 TRIMMED.png
  
  convert \( ORIGINAL2.png -bordercolor none -border 1x0 \) -size 1x1 xc:black -gravity west -composite -size 1x1 xc:black -gravity east -composite -size 1x1 xc:black -gravity north -composite -fuzz 10% -trim +repage -bordercolor white -shave 1x0 TRIMMED2.png
  
  convert \( ORIGINAL3.png -bordercolor none -border 1x0 \) -size 1x1 xc:black -gravity west -composite -size 1x1 xc:black -gravity east -composite -size 1x1 xc:black -gravity north -composite -fuzz 10% -trim +repage -bordercolor white -shave 1x0 TRIMMED3.png
  </code></pre>
  <p>If someone could please explain what I am missing in terms of this height issue that would be really appreciated.</p>
  <p><a href="https://i.stack.imgur.com/S56lq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S56lq.jpg" alt="" /></a>
  These are the 3 ORIGINAL files and the 3 outcomes showing how the outcome changes with the original file changes.</p>
  <p><a href="https://i.stack.imgur.com/RcPXU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RcPXU.jpg" alt="" /></a>
  This is what I am trying to acheive - delete the empty space from the bottom of the image. I want no space after the image at the moment if it is too high I still get space underneath (see the last outcome, bottom right)</p>
  <h6>---- BELOW ARE JUST THE ORIGINAL FILES IF ANYONE WANTED TO TRY IT ON THEIR SETUP ETC ----</h6>
  <p><a href="https://i.stack.imgur.com/dQqUV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dQqUV.png" alt="My original attempt" /></a>
  <a href="https://i.stack.imgur.com/zqPxn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zqPxn.png" alt="Here you can see lots of space" /></a></p>
  <p><a href="https://i.stack.imgur.com/8GHIW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8GHIW.png" alt="My second attempt" /></a>
  <a href="https://i.stack.imgur.com/9LSpZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9LSpZ.png" alt="Trimmed right to the bottom" /></a></p>
  <p><a href="https://i.stack.imgur.com/CSZjq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CSZjq.png" alt="My 3rd attempt" /></a>
  <a href="https://i.stack.imgur.com/2W231.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2W231.png" alt="Small gap leading me to beleive there is some minimum height coming from somewhere" /></a></p>