Yes, there is a program called pishrink that can do this. You must run it in linux. I used a small pi image to boot up to a command prompt, and shrank the image stored on an external usb drive.
It ran for literally two days, but knocked about 10 gigs of a 128gb image that was like 200mb too large.