Resize with gparted or your favorite disk tool and then do the math to dd just a bit more than than your needed partition(s). 4M times 1000 is 4000M

dd bs=4M count=1000 if=/dev/sdb of=RaspberryPI/2015-05-05-raspbian-wheezy-pi2-withRTC-1.0.img