ImageOptim works by applying lossless compression techniques to reduce the file size of images without affecting their visual quality. It supports various image formats including JPEG, PNG, and GIF. The tool removes unnecessary metadata and optimizes the color profiles to achieve the smallest possible file size.