Search code examples
imagemagickimagemagick-convert

how to convert scanned jpg files to pbm format losslessly?


Using ImageMagick's convert utility to convert some scanned jpg files to pbm files.

However, even if the option -quality 100 is used, the pbm's resolution still looks worse than the original scanned jpg file.

Worse, the scanned jpg file is a colored one, while the converted pbm is black and white.

Info of original jpg:
image size: 2256 × 1568 pixels
dpi: 300 pixels/inch
color model: RGB

info of the converted pbm:
image size: 2256 × 1568 pixels
dpi: 72 pixels/inch
color model: Gray

Currently, here is what I did to convert the format:

qiang@bonjour:~/scan$ convert scan000.jpg scan000.pbm

Am I missing any option to use with convert? As I mentioned earlier, -quality 100 had been tried, but to no avail.


Solution

  • Using ImageMagick, I think you want to output to PPM not PBM. Try

    convert image.jpg image.ppm
    

    or try the ascii version by using

    convert image.jpg -compress none image.ppm
    

    PBM is binary (black/white) and PGM is grayscale. If you want to keep color, then you need to use PPM.

    Unfortunately, I believe that ImageMagick can only read DJVU format images. So you cannot write to it directly from ImageMagick.