IMSLP:Image Conversion

(Redirected from Image Conversion)

How to convert low resolution and/or colors images of scores from ismlp or from third party found in the net (e.g. BSB) to high resolution, monochrome scores.


Step 1: Obtaining a set of images from a pdf

Skip this step if you already have a set of jpg images.

Procedure 1

Install ImageMagick and pdftk and Ghostscript.
Type pdftk yourpdfscore.pdf burst output p%1d.pdf
This will produces pages p1.pdf, p2.pdf etc. unless it fails depending on the program that produced the original pdf. Then try a method for Locked PDFs.
To convert them to jpg create a batch file named pdf2jpg.bat containing:
FOR /L %%A IN (%2,1,%3) DO magick -quality 100%% -density %1 p%%A.pdf p%%A.jpg
and type pdf2jpg <density> 1 <last page number> Choosing the right density requires some care. Magnify a lot a note head of a pdf and a jpg page and find the density so they look the same.

Procedure 2

type pdfimages -png yourpdfscore.pdf p . This will produce pages p-001.png, p-002.png etc. There is no need to provide the density. Replace jpg in either procedure of Step 2 with png or convert the pngs to jpg with imagemagick.

Step 2: Converting to high resolution monochrome images

Procedure 1

To convert images of scores from third party found in the net (e.g. BSB) to high resolution monochrome images, it is a good idea to use an image converter such as IrfanView (available for free download). This software offers batch conversion, which means you can convert a large number of images automatically with the same parameters. Instead of resizing the single pixels independently, it uses a Lanczos filter, which results in better resolution (instead of just bigger pixels).

How to work with IrfanView

In the 'File' menu, open 'Batch Conversion/Rename...'
IrfanView BatchConversion.jpg
Here you can choose the folder which contains your original score images and also one where the converted output will be saved.

Use the image settings window with the 'Set advanced options' button to set the conversion you like for all images (e.g. resizing - this should always be done with 'Use Resample function' for high quality; otherwise, it makes no sense at all as it results in bigger files).
IrfanView ImageSettings.jpg

Finally, the output format should be set to TIFF CCITT Fax 4 compression. This automatically changes the images to monochrome, as the format only allows black and white pixels.
IrfanView TIFFsaveOptions.jpg

Procedure 2

With Imagemagick: edit a batch file named jpg300.bat containing:
FOR /L %%A IN (%1,1,%2) DO magick p%%A.jpg -filter lanczos -resize 300%% p%%A.jpg
and type jpg300 1 <last page number>.
Adapt 300%% to {600 divided by the estimated density of the original images}.

Crop the margins and delete the pencil markings with Irfanview. De-skew the pages with irfanview or Imagemagick if necessary.

Edit a batch file named jpg2tif.bat containing:
@FOR /L %%A IN (%2,1,%3) DO (magick p%%A.jpg -compress group4 -threshold %1%% p%%A.tif)
and type jpg2tif <threshold> 1 <last page>. Finding the right threshold between 1 and 100 requires some care.

Step 3: Assembling the tifs into a single pdf

Use one of the procedures Nos.1-5/6 of Scanning music scores