I want to get the coordinates of the inner rectangle of a wonky image on a transparent background.
The inner rectangle I look for is the biggest possible one without transparency.
Background: I make image stackshots with same perspective but different focus from microscopic motives. I am aligning the images with some hugin tools. The aligned images are fused together with enfuse to get one overall sharp image.
The aligning process distorts the single shots. and I need to find the region that is shared by all of them.
ImageMagick already helps me here with "-evaluate-sequence min": I get an image that only contains pixels that are shared by all images. If one of the source pixels is transparent, the resulting pixel is transparent, too:

Fred's innercrop script gives me the red rectangle and its coordinates. With these coordinates I can crop all source images.
So far, my problem is already solved.

I want to ask if there is a possibility to do this special task with a few lines instead of Fred's long script that I could include in my own code.
Is there something like a -trim-hard command? The regular -trim only goes up to the first non-transparent pixels. I would need a trim that removes all transparent pixels and gives me the coordinates of the result.
Any ideas?
---------
Running on Debian with:
$ convert -version
Version: ImageMagick 7.0.8-15 Q16 x86_64 2018-12-02 https://imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): fontconfig freetype jbig jng jpeg lzma openexr pangocairo png tiff x zlib