I recently wrote a jython script that can be used as an ImageJ/FIJI plugin. The plugin will automatically crop black edges away from images using the largest rectangle algorithm.
Notes on using the largest rectangle algorithm for automatically cropping crooked images.