rewrite images in a pdf file in an automated fashion