Crop image based on alpha

Hello,

I am trying to figure out way how to automatically crop image based on its alpha channel - so that each side (top, bottom, right, left) is cropped up to the point where alpha > 0 (and portions where alpha is 0 are basically discarded). Please could someone give me a hint how approach such thing? Thanks.

Oh, I am sorry for duplicate thread - I just found this exact question already on forums: