Batch Converting/Standardizing Multiple Mixed Resolution Images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
thatoldfool
Posts: 2
Joined: 2015-06-07T01:51:13-07:00
Authentication code: 6789

Batch Converting/Standardizing Multiple Mixed Resolution Images

Post by thatoldfool »

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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Batch Converting/Standardizing Multiple Mixed Resolution Images

Post by snibgo »

I suppose each PDF page contains exactly one image?

Others here have more expertise at PDF than me, but I would try:

Code: Select all

convert -density XX in.pdf out.pdf
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.

Code: Select all

convert page-0123.tiff -resample 300 out-page-0123.tiff
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":

Code: Select all

convert page-0123.tiff -resample 300 -extent WWxHH out-page-0123.tiff
where WW and HH are the maximums.

3. Reassemble the PDF:

Code: Select all

convert out-page-*.tiff out.pdf
snibgo's IM pages: im.snibgo.com
thatoldfool
Posts: 2
Joined: 2015-06-07T01:51:13-07:00
Authentication code: 6789

Re: Batch Converting/Standardizing Multiple Mixed Resolution Images

Post by thatoldfool »

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
Post Reply