As far as I know
For jpeg images, You can set img.dataMode = Image.MODE_MIME or Image.MODE_MIME/Image.MODE_IMAGE enables MIME data tracking of images.When MIME data is tracked, PDF canvases can embed JPEGs directly into the output, rather than re-encoding into PNG. This can drastically reduce filesize and speed up rendering.
For png images, I couldn't find any configurations that can optimize file size, and I analyzed that after embedding png images into PDFS, they should be compressed to FlateDecode
Can png be embedded in PDF using the DCTDecode compression method?