add main image compression function