7

I've tried to find a simple explanation for several hours but I just can't seem to find anything useful. I'm primarily a Windows programmer with some experience with Linux-based OSes. For some reason doing apt install imagemagick only gives me a really old version (pre-2012) and there's a change in the later versions that I need, which means I need to build from source.

Compiling IM 7 on Ubuntu 18.04 is simple enough: Download tar.gz, extract, ./configure, make and make install. However it seems that PNG support is not included by default (why??).

I've tried doing ./configure --with-png but that didn't achieve anything (I see --with-png=yes no, which presumably means "yes, you've asked for PNG support but no, I haven't given it to you"). I've seen many forum posts and SE questions about this, but everyone asking seems to have some prior knowledge which I am clearly missing and the questions appear to be about some later step in the process.

So, what do I actually need to do to get PNG support?

(And as some bonus questions: Why is there no documentation for this? Why does it not include PNG support out of the box? Why are there no prebuilt binaries for Ubuntu?)

Related question: Imagemagick still exists after apt remove?

Clonkex
  • 1,682
  • Try to install it using apt first. It should install dependencies. Then remove imagemagick without removing its dependencies and try again your manual compilation. – Gryu Mar 12 '20 at 00:27
  • @Gryu How do I remove imagemagick without removing its dependencies? – Clonkex Mar 12 '20 at 00:29
  • sudo apt remove imagemagick removes only imagemagick. What is your imagemagick version from repositories? – Gryu Mar 12 '20 at 00:31
  • 1
    @Gryu If you mean the version I get with apt install, it said Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114. Though since building from source I seem to only get the new (PNG-less) version when I run (for example) magick -version – Clonkex Mar 12 '20 at 00:37
  • @Clonkex I have not experimented with this but perhaps a small variation of this question and answer might do the trick: https://askubuntu.com/q/745660/57576 – andrew.46 Mar 13 '20 at 20:24
  • Have you installed libpng and libpng-devel with apt? The png support is enabled by default in 7.x and should work. – frozendwarf Mar 12 '20 at 00:14

4 Answers4

6

I highly recommend ImageMagick Easy Install (IMEI):

https://github.com/SoftCreatR/imei/

It tracks down all the source/development libraries needed for the additional ImageMagick "delegates" (image formats in IM-speak). Plus, it can also incrementally update your local install from newer source after the initial installation.

Installation steps as of now:

git clone https://github.com/SoftCreatR/imei
cd imei
sudo ./imei.sh
Zanna
  • 72,471
  • 1
    You should at least provide som installation details from that link. – Artur Meinild Mar 15 '21 at 13:21
  • 1
    Works like a charm. – SGL Apr 11 '21 at 01:19
  • This is working well for me doing a multi-architecture (amd64 & arm64) docker build which means I need to build ImageMagick from source. Includes all the delegates (e.g. JPEG & PNG) we need. – jenglert Jan 08 '25 at 22:17
  • It didn't work for me because of ImageMagick is already installed via apt/dpkg. Please uninstall it first, before proceeding, now after sudo apt remove imagemagick the command sudo ./imei.sh started but takes its time. Now the command magick is installed and at least displays some usage information. I'm excited to evaluate if all those promises are true or if there are more obstacles. – Gyro Gearloose Aug 14 '25 at 10:24
4

ImageMagick doesn't find libpng on its own. The simplest way to tell it how to find, compile and link with libpng is by installing libpng followed by pkg-config:

sudo apt install build-essential libpng-dev pkg-config

Now you can see if it works:

./configure | grep -i png

checking for libpng >= 1.0.0... yes PNG --with-png=yes yes CFLAGS = -I/usr/include/libpng16 -fopenmp -Wall -g -O2 -mtune=amdfam10 -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 LIBS = -lpng16 -lz -lz -lm -lpthread DELEGATES = png zlib

  • "New contributor" with 166k on SO lol. Cheers for the answer; if I have to build IM again at some point I'll try this method :) – Clonkex Apr 07 '22 at 21:59
0

I am not sure what error message you were getting, but I was getting convert: no decode delegate for this image format `JPG' @ error/constitute.c/ReadImage/562 when working with jpegs with a fresh ImageMagick install from source.

To resolve it:

  1. uncomment deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted in /etc/apt/sources.list

  2. install dependencies

sudo apt update
sudo apt build-dep imagemagick
  1. Reinstall ImageMagick
./configure
make
sudo make install
sudo ldconfig /usr/local/lib

source: https://linuxconfig.org/how-to-install-imagemagick-7-on-ubuntu-18-04-linux

joe
  • 101
0

In case anyone is looking to do this in docker with ImageMagick Easy Install:

FROM eclipse-temurin:21-jdk-jammy

Hardcode version to avoid unexpected breaking changes

ARG IMAGE_MAGICK_VERSION=7.1.1-43

Install ImageMagick using IMEI - ImageMagick Easy Install

https://github.com/SoftCreatR/imei

RUN t=$(mktemp) &&
wget 'https://dist.1-2.dev/imei.sh' -qO "$t" &&
bash "$t" --imagemagick-version $IMAGE_MAGICK_VERSION &&
rm "$t"

Includes lots of delegates:

# magick -version
Version: ImageMagick 7.1.1-43 Q16-HDRI aarch64 afd817ca6:20241222 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5)
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc heic jbig jng jp2 jpeg jxl lcms lqr ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zip zlib zstd
Compiler: gcc (11.4)
jenglert
  • 101