Compresses images with macro

Hello, I need a macro that allows me to compress an image. I already have a macro which resizes and replaces the images but I have to compress them one by one each time. That’s why I want to know how to compress an image with macros so that I can integrate it.