Good afternoon,
Situation:
I'm repairing a poorly scanned PDF in ScanTailor. Whoever scanned the book scanned over 3 separate sessions using at least 2 different DPI's.
Problem:
Mixed resolutions mean that page sizes appear to vary. I need to somehow batch convert a directory of images to a standard resolution and size.
Help me ImageMagick, you're my only hope!
Thanks in advance!
-tof
Batch Converting/Standardizing Multiple Mixed Resolution Images
-
- Posts: 2
- Joined: 2015-06-07T01:51:13-07:00
- Authentication code: 6789
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Batch Converting/Standardizing Multiple Mixed Resolution Images
I suppose each PDF page contains exactly one image?
Others here have more expertise at PDF than me, but I would try:
Choose XX to be the greatest scanning density used.
It may be better to do the job in stages:
1. Extract all the pages with pdfimages.
2. Resample as required to make them all the same dpi.
With luck, all the pages are now the same density and size (in pixels and inches). If they are not quite the same size, also use "-extent":
where WW and HH are the maximums.
3. Reassemble the PDF:
Others here have more expertise at PDF than me, but I would try:
Code: Select all
convert -density XX in.pdf out.pdf
It may be better to do the job in stages:
1. Extract all the pages with pdfimages.
2. Resample as required to make them all the same dpi.
Code: Select all
convert page-0123.tiff -resample 300 out-page-0123.tiff
Code: Select all
convert page-0123.tiff -resample 300 -extent WWxHH out-page-0123.tiff
3. Reassemble the PDF:
Code: Select all
convert out-page-*.tiff out.pdf
snibgo's IM pages: im.snibgo.com
-
- Posts: 2
- Joined: 2015-06-07T01:51:13-07:00
- Authentication code: 6789
Re: Batch Converting/Standardizing Multiple Mixed Resolution Images
snibgo,
Bam, I combined your suggestions with a few others I read about here on the forum and my goal was achieved. Steps:
1. Export PDF to images
2. mogrify -path ~/Desktop/test/converted/ -format jpg -resample 300 -resize 3508x2480 *.jpg
resample on its own didn't do the trick for some reason.
Thanks for the suggestion! What an amazing programme...
-tof
Bam, I combined your suggestions with a few others I read about here on the forum and my goal was achieved. Steps:
1. Export PDF to images
2. mogrify -path ~/Desktop/test/converted/ -format jpg -resample 300 -resize 3508x2480 *.jpg
resample on its own didn't do the trick for some reason.
Thanks for the suggestion! What an amazing programme...
-tof