[personal profile] djinncoyote
Problem: My scanner produces PDF files with faint and blurry text.

I can sharpen the images quite well with IrfanView, but the procedure isn't simple.

Method #1 - using the GUI (can be used to sharpen multiple files at once)

1. Open IrfanView.
2. Select File - Batch Conversion/Rename...
3. On the Batch Conversion page, select these options:

    Work As: Batch Conversion
    Output Format*: TIF
    Use advanced options (for bulk resize...) : selected
    Output directory for result files: select and/or create a (temporary) subdirectory

(*For multi-page PDF files, don't select the PDF output format, as then the changes will only be applied to the first page. This seems to be a bug. For all pages to get updated, TIF must be selected. We will do extra steps to convert the TIF back to PDF.)

4. Click the "Advanced" button and set these options:

    Auto Adjust Colors
    Contrast (40)
    Saturation (30)
    Overwrite existing files
    Apply changes to all pages (TIF/PDF saving)

Click the "OK" button.
The options and numbers may be adjusted, depending on how much you want to sharpen and darken the text. Other effects may also be selected, if desired.
(This step only has to be done once. After that, the same settings are kept.)

5. Select one or more PDF files and click "Add".
6. Click "Start Batch".
7. After the conversion is complete, click "Return to Batch".

8. Change "Output Format" to "PDF".
9. Un-select "Use advanced options...".
10. Click "Remove All" to clear the output box.
11. Navigate to the output directory, select the TIF file(s) and click "Add".
12. Click "Start Batch".
13. The final PDF file(s) will be generated in the output directory.

(A different output directory must be used, as IrfanView will not overwrite the original PDF files. If you use the same directory, IrfanView will throw an error.)

Method #2 - using a batch file

1. Perform steps #1 - 4 above. After selecting the Advanced settings, click the "Save settings" button on that page. Save the settings with a filename of "i_view32.ini", in a folder of your choosing.

2. Create a batch file with content such as the following:

   "C:\Program Files (x86)\IrfanView\i_view32.exe" %1 /advancedbatch /ini="C:\bat\irfanviewSharpen" /convert=%~n1.tif

   "C:\Program Files (x86)\IrfanView\i_view32.exe" %~n1.tif /convert=%1

   @del %~n1.tif

The batch file takes a single parameter, which is the input PDF file.

The 1st line of the batch file converts the PDF to a TIF file, applying the advanced options to sharpen the image. The "/ini" option should be set to the folder where the "i_view32.ini" file was saved.
The 2nd line of the batch file converts the TIF file back to a PDF file, overlaying the original PDF file.
The 3rd line of the batch file deletes the intermediate TIF file.

Update (2014/02/09): See this post for information on how to avoid losing resolution in the converted PDF file when using the above methods.

Update (2016/01/20): For Method #2, I forgot to mention that I invoke the batch file by right-clicking on a PDF file from within Windows Explorer, and then selecting "Open With..." This causes the selected file-name to be passed to the batch file as the %1 parameter.

The first time you use "Open With...", you can select "Choose default program..." and click the Browse button to select your batch file. Unselect "Always use the selected program to open this kind of file", so that your default program for viewing PDF files won't be changed. The next time you use "Open With..." on a PDF file, your batch file should be included in the sub-list for you to select from.

Update (2016/02/14): IrfanView has another method of sharpening an image, using an "Unsharp mask". This may give even better results than the above methods. This option is available via the menu item "Image - Effects - Effects browser..." When editing a multi-page image, only the current page is updated.

The Unsharp mask can be applied to an image from the command line, using the /effect option. But for a multi-page image (whether PDF or TIFF), effects are applied only to the first page. To apply an effect to all pages, you have to extract all the images from the multi-page file (/extract option), and then apply the effect to each separate image. Then you have to combine the images back into a single file. This page gives an idea of how to do that. There are issues with this method if your paths or file-names contain spaces.

A much simpler option is to use ImageMagick, which can apply an Unsharp mask to all pages in a multi-page PDF or TIFF file in a single step.



February 2017

121314151617 18

Most Popular Tags

Active Entries

Style Credit

Expand Cut Tags

No cut tags