How To Shrink Sparsebunble Image in Mac OS X

Sparsebundle, such as the image file used for Time Machine backup over network, doesn’t shrink even when the content has reduced in size. This is how you shrink the image file to reclaim some disk space: hdiutil compact path/to/sparsebundle