I have a large amount of 1024x1024 images that are mostly transparent pixels. I need to crop these images to the smallest possible centered square that includes all pixels. In other words: I need to trim the canvas equally, on all sides, until I run into a non-transparent pixel.
Example 1:
The 1024x1024 image is completely transparent, except for one black pixel located at 1003, 1011. The resulting image is 1011x1011.
Example 2:
The 1024x1024 image is completely transparent, except for a 100x200 black rectangle in the dead center. The resulting image is 200x200.
Photoshop's "trim" command seems a step in the right direction, but most options I've found trim everything to visible pixels which makes me lose the centerpoint reference.