And then some scripts: Fit Canvas to Layer and Fit Layer to Canvas. The first is an original, which I made when I had to adapt a standard template with some preset layer effects to different images - just using Trim wasn't always an option, like when there was a transparency and the image dimensions had to remain the same, so I just couldn't trim transparent pixels.
The latter has been originally published elsewhere on a Adobe user forum, which has since disappeared. It was slightly edited by me for reasons I cannot remember anymore.
https://codeberg.org/otterside/photoshop-scripts