How to crop with edge-detection using imagemagick Let's say I have an image of an object against a white background. I want to crop so that the image fills the available space.
This takes 10px off:

convert original.png -shave 10x10 shaved.png


How would I implement something like this that detects the edges of the object, thus cropping a variable number of pixels from each side?
Try -trim instead of -shave:

convert original.png -trim trimmed.png


See the docs for this and other options.