gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -sOutputFile=output.pdf input.pdf
img2pdf image1.jpg image2.jpg image3.jpg image4.jpg image5.jpg -o temporary.pdf
ocrmypdf --optimize 3 --dcs-level2 temporary.pdf final_compressed.pdf
--remove-background
-c, --clean
--jbig2-lossy --force-ocr