skip to Main Content

Problem

I need to convert a multipage pdf to jpg-files but ImageMagick keeps throwing errors that are hard to interpret.

Installing ImageMagick

At first I installed it using apt-get, but as I could read that several people had problems doing that, i ended up installing it from source.

My linux distribution (A Docker image):

>lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

Installing ImageMagick from source:

# Installing build tools and ghostscript
apt update
apt-get install -y build-essential make ghostscript

# Downloading imagemagick
wget https://www.imagemagick.org/download/ImageMagick.tar.gz

# Installing and cleaning up
tar xvzf ImageMagick.tar.gz && cd ImageMagick-7* && ./configure && make && make install && ldconfig /usr/local/lib && cd .. && rm -r ImageMagick-7*

# Checking ImageMagick version
>magick -version
Version: ImageMagick 7.0.10-60 Q16 x86_64 2021-01-25 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5)
Delegates (built-in): jpeg x xml zlib

Converting files

# Image to image
>convert test.jpg test.png

# PDF to image 
>convert test.pdf test.jpg
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/572.
convert: no images defined `test.jpg' @ error/convert.c/ConvertImageCommand/3304.

Is Ghostscript the problem?

The Ghostscript installation is a common problem for many, but Ghostscript seems to work fine and produce a jpg-file

# PDF to image with Ghostscript
gs -sDEVICE=pngalpha -sOutputFile=test.jpg test.pdf

Do I have to install more Delegates?

The error suggests that there is something off with my limited delegates, so I thought to install all dependencies up front.

# Listing dependencies
>apt update && apt build-dep imagemagick
Reading package lists... Done
E: You must put some 'source' URIs in your sources.list

This is where I got stuck.

2

Answers


  1. Chosen as BEST ANSWER

    Solution

    It turned you that it was indeed the delegates that were missing. I haven't seen this well described in the documentation or anywhere else.

    NOTE: Delegates should be installed before you install ImageMagick

    Here is how I fixed it:

    # Add source URI or uncomment source URI
    ## Adding URI
    echo "deb-src http://deb.debian.org/debian buster main" >> /etc/apt/sources.list
    apt update
    ## Uncommenting URI
    sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
    sudo apt update
    
    # Installing dependencies
    apt-get build-dep imagemagick
    

    Now I can convert pdf to jpg!


  2. My solution was to reinstall imagemagick, but following the steps in the answer of andrew.46 at https://askubuntu.com/questions/745660/imagemagick-png-delegate-install-problems/746195#746195

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search