TImage32.CropTransparentPixels

function CropTransparentPixels: TRect;


Trim transparent edges until each edge contains at least one opaque or semi-opaque pixel.

This function returns the bounds of the cropped region (before the image is resized).

uses Img32, Img32.Fmt.PNG;
...
img := TImage32.Create;
img.LoadFromFile('star.png');
img.CropTransparentPixels;
//HatchBackground
img.SaveToFile('star_cropped.png');
img.Free;
    
Before:
After: