PDF To JPG

PDF To JPG

I had a need to extract the pages of a PDF as JPG images. I have a Linux VM setup already with tesseract as an OCR server, so I decided to add this ability to it. The first choice was to install ImageMagick and use it’s convert utility.

After using yum install ImageMagick, when I tried to convert with ICC files like below;

convert -verbose -density 300 -colorspace rgb SaleCat.pdf[10-20] -profile eciCMYK.icc -profile eciRGB_v2.icc -quality 100 y-%04d.jpg

I got this message:

convert: delegate library support not built-in `SaleCat.pdf' (LCMS) @ warning/profile.c/ProfileImage/565.

I ran the following to see the delegates installed:

convert -list configure | grep -i "delegates"

The results showed the lcms delegate wasn’t setup:

DELEGATES     bzlib fontconfig freetype gs jpeg jng jp2 lzma openexr pango png rsvg tiff x11 xml wmf zlib

I verified that lcms was already installed with yum install lcms2 (it was).

So it appears that I needed to rebuild ImageMagick from source to include the lcms2 delegate. I removed Image magic with “yum remove ImageMagick” first.

I made sure gcc was installed:

yum install gcc

Then downloaded and configured the ImageMagick source:

wget https://imagemagick.org/download/ImageMagick.tar.gz
tar xvfz ImageMagick.tar.gz
cd ImageMagick-*
./configure --with-lcms=yes

The config should show that lcms was now enabled, but it wasn’t:

LCMS              --with-lcms=yes             no

So I looked at config.log to see the details:

     configure:31839: checking for lcms2 >= 2.0.0
configure:31846: $PKG_CONFIG --exists --print-errors "lcms2 >= 2.0.0"
Package lcms2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `lcms2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lcms2' found

I made sure that lcms2 devel was installed:

yum install lcms2-devel

I tried again to build:

./configure  --with-lcms=yes


And this time the config looked good:

LCMS              --with-lcms=yes             yes

And so I built and installed ImageMagick from the source:

make
make install
make clean

Now I can run convert from /usr/local/bin/convert and process with icc files.