I have a multi-page PDF with photographed book pages. I want to remove gradients from every page to prepare for optical character recognition.
This command works fine on a PNG of a single page:
convert page.png \( +clone -blur 0x64 \) -compose minus -composite -channel RGB -negate page_deblurred.png
However, as soon as I try this on a multi-page PDF by using this command...
convert full.pdf \( +clone -blur 0x64 \) -compose minus -composite -channel RGB -negate full_deblurred.pdf
...I get a single-page PDF with inversed colors overlaid with text from several pages.
How do I tell imagemagick to process every page like it does with the PNG and return a multi-page PDF to me?
This should do what you want in ImageMagick in one command line. You have to use -layers composite and separate your pdf and your blur processing by null:. This is the same process as merging animated gifs.
convert -density 288 image.pdf -write mpr:img null: \( mpr:img -blur 0x64 \) -compose minus -layers composite -channel RGB -negate -resize 25% image_deblurred.pdf