Here is a script I wrote last year when shrinking servers.
The script will reduce the file size of the image and reduce the partition in the image.