Removing unused images

I am trying to migrate a WP site, and found that it has grown to about 500MB. The standard import plugin appears to run out of memory when I try to import the XML file “with attachments.” I found that pretty much all of the 500MB is taken up by images that were initially uploaded and then re-sized several times, and WP is keeping every version.

Is there a way to force WP to keep only the version that’s in use, and remove the rest?

I understand the reason why the original version is kept (still I’d like to remove it).