I often have images like the one below, where a small image is positioned on a transparent background. The background can't be seen here, but it's definitely there - just download the image and see.
Is it possible to use any tool (Gimp or Photoshop) to automatically crop the transparent background to the borders of the inner element? For example, the size of this image is 320x200 and after cropping its size would be the size of the pink circle.