resizing partitions on SD Card

I have a 4GB (3.62GB fat32 formatted) SD card and just downloaded images_bone-debian-7.4-2014-04-23-2gb.img.xz . Note this is intended to work with a 2GB SD card which wastes much of the card I have to use much less anything smaller is getting difficult if not impossible to find. How can I recover the lost space on the SD card and expand the partition holding my root filesystem once the card is imaged? or as an alternative, how can I modify this image so it cleanly writes and uses the full space of the 4GB SD card I have.



cd /opt/scripts/tools/
sudo ./