import sys
from pypdf import PdfWriter

pdf_file=sys.argv[1]
print(pdf_file)

writer = PdfWriter(clone_from=pdf_file)

for page in writer.pages:
    for img in page.images:
        img.replace(img.image, quality=20)

with open(pdf_file, "wb") as f:
    writer.write(f)