Unlike IrfanView, which requires several steps to sharpen a multi-page PDF, ImageMagick can do it in a single step, using its "convert.exe" command line utility.

I've found that the following parameters give good results for scanned text documents.
They use the "unsharp" parameter, which despite its name is used to sharpen an image.

For 300 dpi scanned documents:

C:\util\ImageMagick-6.9.3-4-portable-Q16-x64\convert.exe -density 300 -unsharp 10x3.2+5.0+0.10 -compress jpeg -quality 75 [input file] [output file]

For 600 dpi scanned documents:

C:\util\ImageMagick-6.9.3-4-portable-Q16-x64\convert.exe -density 600 -unsharp 30x5.5+3.0+0.10 -compress jpeg -quality 75 [input file] [output file]

References:
Sharpening using ImageMagick
ImageMagick command line options
In this post, I gave instructions on how to sharpen blurry PDF files using IrfanView.

I noticed recently however, that sharpening a PDF file in this manner may result in a loss of resolution in the sharpened file. When one views the sharpened PDF file at a high zoom level, much more pixelation may be visible than in the original file at the same zoom level.

After some research, I've figured out how to avoid such loss of resolution.

IrfanView's settings are stored in an "i_view32.ini" file. The file may exist in one or more of the following locations:
- the IrfanView program install folder
- C:\Users\[user-name]\AppData\Roaming\IrfanView
- C:\Users\[user-name]\AppData\Local\VirtualStore\Program Files (x86)\IrfanView

On my Windows 7 computer, different versions of the file are in each of these 3 folders, but based on the file timestamps, the one in the last folder is the one which actually gets updated and used.

Two sections of the ini file are related to viewing and saving PDF files.

One section is labelled "[Ghostscript]". This has the Ghostscript PlugIn settings which are used for reading the PDF image data into memory and rendering it. The values can be updated from within IrfanView by selecting Options - Properties/Settings... - Plugins - Postscript Options. My original Ghostscript PlugIn DPI settings were 96x96, which explains why I was losing resolution when re-saving PDF files. The DPI settings here should be set at least as high as the resolution of the original file. If you scan files at 300 dpi, then use 300x300. If you scan at 600 dpi, then use 600x600.

Note that when using higher DPI values, the conversion process will take longer, and the intermediate TIF file will be much larger in size. Adequate disk space is required.

The other relevant section is labelled "[ImPDF]". This corresponds to the "PDF Settings" window that is shown when saving a file in IrfanView to PDF format. To avoid large PDF file sizes, "Activate Compression" should be selected on the "Compression" tab. For both 300 and 600 dpi, I've found that the "JPEG (high quality)" setting gives very good quality with relatively small file sizes.

Using a batch file

If using the batch file method of sharpening a PDF file as mentioned in the prior post, the ini file that you use should contain both the [Ghostscript] and [ImPDF] sections. I've found it easiest to update the DPI and Compression settings as mentioned above (as well as the Advanced Batch Conversion settings as mentioned in the prior post) from within IrfanView, and then to copy the ini file from the above-mentioned location to my chosen folder.

It is best to update your batch file to use the copied ini file on both steps. That way, your batch file will always give the same results regardless if you later change the settings within IrfanView while working with other files.

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

   "C:\Program Files (x86)\IrfanView\i_view32.exe" %~p1\%~n1_x.tif /ini="C:\bat\irfanviewSharpen" /convert=%~p1\%~n1_x.pdf

   @del %~p1\%~n1_x.tif

The above commands keep the original PDF file unchanged, and create another PDF file with "_x" on the end of the name. You can compare both files to verify that no loss of resolution has occurred, and that the amount of sharpening is satisfactory. If not, try updating each of the settings that were mentioned until you get the desired results.
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
    Sharpen
    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.
Digital cameras which are manufactured nowadays tend to embed a lot of extra information in each photograph taken by the camera. This data is generally in the form of EXIF tags, and may include the make and model of the camera, the date and time the photo was taken, various camera settings for the particular shot, a thumbnail image, geolocation data (if the camera has GPS), and other details.

I only recently discovered that some cameras embed a thumbnail image within each photograph. I was even more surprised to discover that the original thumbnail may be retained, even after you have edited or cropped the image. Whether or not the thumbnail is updated depends on the image editing software that you use. Based on some testing I did, Windows Paint updates the thumbnail when the image is edited. IrfanView doesn't seem to update the thumbnail when the image is edited. Other software may or may not update the thumbnails.

If you post photographs online, you may want to consider the data embedded in your images. If you have edited your photos, do you want other people to be able to see a small version of the original image via the embedded thumbnail? If your camera has GPS, do you want other people to be able to find out the exact location of where a photograph was taken, without you explicitly telling them? Do you want people to be able to find out when a photo was taken, and with what kind of camera? You may or may not care about these details. If you do care, then you should consider stripping out the embedded data before posting the photos online.

Many popular websites appear to automatically strip out embedded data from photographs, when you upload them. This is likely done to reduce the size of the files and to reduce the amount of space required for storing the files. To determine whether a website strips EXIF data from an image, you can download the image after uploading it, and compare it to the original using software which displays the embedded data.

One program which lets you view embedded image data is WildBit Viewer. To view the embedded data, navigate and select the image file in WildBit's navigator pane, then select the menu item "File - Image Info". If the image contains an embedded thumbnail, it will be displayed in the upper right portion of the "Image Info" window. Other EXIF data will be displayed in the bottom portion of the window.

IrfanView also lets you view some of the embedded image data, if you have installed the necessary plugin. Selecting the menu item "Image - Information" will bring up a window with an "EXIF info*" button (if the image contains EXIF data). Selecting the button will display the embedded data. However, embedded thumbnails are not displayed.

IrfanView provides the option to either retain or strip out embedded image data when saving files. The "Save As" dialog for JPG files includes the following options:

  • Keep original EXIF data (if JPG to JPG)

  • Keep original IPTC data

  • Keep original JPG-comment

  • Keep original XMP data

In order to keep the embedded data, the above 4 options should be selected. In order to remove the embedded data (including any embedded thumbnail), those options should be unselected.

ExifTool is a command-line program which lets you extract, view, and/or update the metadata in image files. You can pass the program various parameters, depending on what kind of data you want to extract. For example, the command:
   "exiftool.exe -a -u -G image.jpg"
will extract and display all embedded info, including group names, from the file named "image.jpg".
The command:
   "exiftool -b -ThumbnailImage image.jpg > thumbnail.jpg"
will extract the embedded thumbnail from the file "image.jpg" and will save it as a separate file named "thumbnail.jpg".

Profile

djinncoyote

September 2017

S M T W T F S
     1 2
3456789
10111213141516
17181920212223
24252627282930

Syndicate

RSS Atom

Most Popular Tags

Active Entries

Style Credit

Expand Cut Tags

No cut tags