#lang en <> = Config = New installations of !ImageMagick sometimes don't have the best configuration out of the box. For example it can prevent you from splitting a pdf file into separate files, or it can run out of it's specified memory limits. Here are some settings I like to change: == Increase Memory limits == On Debian, in `/etc/ImageMagick-/policy.xml` search for the lines containing `domain="recource"` I replaced these with the following {{{ }}} == Allow unpacking of PDF's == By default you are protected from unpacking/extracting data from PDF files, because of a (patched) [[https://www.kb.cert.org/vuls/id/332928/|vulnerability in Ghostscript]]. This is the interpreter that !ImageMagick uses and it used to be vulnerable to remote code execution. However this should be patched by now, and as long as you don't plan on working with untrusted files, you should be fine. To allow this comment out the following line {{{ }}} = Commands = == Increasing contrast on (bitmap) PDF files == First, break up the PDF into separate jpg files. (!ImageMagick can't deal with pdf directly) {{{ pdfimages -j file.pdf page }}} This command will extract all jpg files from a pdf, if the pdf doesn't consist of only jpg files, try this command: {{{ convert file.pdf page-%03d.jpg }}} Now, modify the images. For example: {{{ convert page-*.jpg -level 25% page_out-%03d.jpg }}} And finally, convert it back into one single PDF file. {{{ convert page_out-*.jpg file_out.pdf }}} == Remove vertical lines from images == The `1x100` and the specified array determine lines from what length should be recognized. Playing around with the values, this worked for me to delete scanner lines. {{{ convert input.jpg -morphology bottomhat "1x100:0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0" -negate output.jpg }}}