- Download and install ImageMagick + Convert Module
- Execute the following command in the console
$ convert -density 200 INPUT.pdf -rotate 0.3 +noise Multiplicative -format pdf -quality 85 -compress JPEG -colorspace gray OUTPUT.pdf
- -density: set the input DPI to 200
- -rotate: set Page rotation to 0.3 degrees
- +noise: add noise to the PDF (other Noise-Options: https://www.imagemagick.org/script/command-line-options.php#noise)
- -format: set format to PDF for the correct sizing (A4)
- -quality: set JPEG Quality to 85%
- -compress: set compress to jpeg (other Compress-Options: https://www.imagemagick.org/script/command-line-options.php#compress)
- -colorspace: set color to gray
from __future__ import print_function
import os
import subprocess
input_dir = "Input/"
output_dir = "Output/"
if not os.path.exists(output_dir):
os.makedirs(output_dir)
for root, dirs, files in os.walk(input_dir):
for file in files:
if file.endswith(".pdf"):
input_filename = os.path.join(root, file)
print ("Process: " + input_filename)
p = subprocess.Popen(
'convert -density 200 '+input_filename+' -rotate 0.3 +noise Multiplicative -format pdf -quality 85 -compress JPEG -colorspace gray '+str(output_dir + file), shell=True)