image optimization, thanks ondrek (CLA on file), fixes #17021