convert image.png -crop 128x128 +repage +adjoin tile-%d.png
http://www.imagemagick.org/script/command-line-options.php#trim
Uses the top-left pixel colour:
convert image.png -trim +repage result.png
+repage removes offset metadata from result.
With fuzzy colour match:
convert image -fuzz 1% -trim +repage result
Usually because the image uses a colour profile which isn't supported on some programs and web browsers. Use -strip
to apply and remove color profiles.
First, create a mask image where it goes from transparent to black. Then run:
convert -compose Dst_In -gravity center ./adenine.png ../mugshot-mask.png -composite adenine-new.png
# source = 84 output = 66, radius = 33
convert input.png -crop 66x66+9+9 +repage \( +clone -fill Black -colorize 100 -fill White -draw 'circle 33,33 33,0' \) -alpha off -compose CopyOpacity -composite output.png
Note the sub command.
convert image.png -gravity center -background transparent -extent `identify -format "%[fx:max(w,h)]x%[fx:max(w,h)]+0+0" image.png` +repage out.png