I'm trying to use ImageMagick 7 in a Docker container. However it doesn't install any delegates, though I added libpng-dev. When I try to get an image inside the container from https with this command:
magick https://www.nasa.gov/sites/default/files/thumbnails/image/moon_mosaic.png ./test.png
I get this message:
magick: no decode delegate for this image format `DAT' # error/constitute.c/ReadImage/738.
This doesn't make sense, since it is a PNG image and not a DAT file.
Here my Dockerfile:
FROM debian:bullseye-slim
ARG IM_VERSION="7.1.0-37"
ARG IM_BUILD_FLAGS="--enable-shared --disable-static --without-modules --enable-delegate-build --disable-docs --with-heic=yes"
WORKDIR /app
RUN apt-get update && apt-get install -y wget && \
apt-get install -y build-essential curl libpng-dev && \
wget https://github.com/ImageMagick/ImageMagick/archive/refs/tags/${IM_VERSION}.tar.gz && \
tar xzf ${IM_VERSION}.tar.gz && \
rm ${IM_VERSION}.tar.gz && \
apt-get clean && \
apt-get autoremove
WORKDIR /app/ImageMagick-${IM_VERSION}
RUN sh ./configure ${IM_BUILD_FLAGS} && make -j && make install && ldconfig /usr/local/lib/
Here the output from the configure part of building ImageMagick:
configure:
==============================================================================
ImageMagick 7.1.0-37 is configured as follows. Please verify that this
configuration matches your expectations.
Host system type: x86_64-pc-linux-gnu
Build system type: x86_64-pc-linux-gnu
Option Value
------------------------------------------------------------------------------
Shared libraries --enable-shared=yes yes
Static libraries --enable-static=no no
Build utilities --with-utilities=yes yes
Module support --with-modules=no no
GNU ld --with-gnu-ld=yes yes
Quantum depth --with-quantum-depth=16 16
High Dynamic Range Imagery
--enable-hdri=yes yes
Install documentation: no
Memory allocation library:
JEMalloc --with-jemalloc=no no
TCMalloc --with-tcmalloc=no no
UMem --with-umem=no no
Delegate library configuration:
BZLIB --with-bzlib=yes no
Autotrace --with-autotrace=no no
DJVU --with-djvu=yes no
DPS --with-dps=yes no
FFTW --with-fftw=no no
FLIF --with-flif=no no
FlashPIX --with-fpx=yes no
FontConfig --with-fontconfig=yes no
FreeType --with-freetype=yes no
Ghostscript lib --with-gslib=no no
Graphviz --with-gvc=yes no
HEIC --with-heic=yes no
JBIG --with-jbig=yes no
JPEG v1 --with-jpeg=yes no
JPEG XL --with-jxl=no no
LCMS --with-lcms=yes no
LQR --with-lqr=yes no
LTDL --with-ltdl=no no
LZMA --with-lzma=yes no
Magick++ --with-magick-plus-plus=yes yes
OpenEXR --with-openexr=yes no
OpenJP2 --with-openjp2=yes no
PANGO --with-pango=yes no
PERL --with-perl=no no
PNG --with-png=yes no
RAQM --with-raqm=yes no
RAW --with-raw=yes no
RSVG --with-rsvg=no no
TIFF --with-tiff=yes no
WEBP --with-webp=yes no
WMF --with-wmf=no no
X11 --with-x= no
XML --with-xml=yes no
ZIP --with-zip=yes no
ZLIB --with-zlib=yes no
ZSTD --with-zstd=yes no
Delegate program configuration:
GhostPCL None pcl6 (unknown)
GhostXPS None gxps (unknown)
Ghostscript None gs (unknown)
Font configuration:
Apple fonts --with-apple-font-dir=default
Dejavu fonts --with-dejavu-font-dir=default none
Ghostscript fonts --with-gs-font-dir=default none
URW-base35 fonts --with-urw-base35-font-dir=default none
Windows fonts --with-windows-font-dir=default none
X11 configuration:
X_CFLAGS =
X_PRE_LIBS =
X_LIBS =
X_EXTRA_LIBS =
Options used to compile and link:
PREFIX = /usr/local
EXEC-PREFIX = /usr/local
VERSION = 7.1.0-37
CC = gcc
CFLAGS = -fopenmp -Wall -g -O2 -mtune=ivybridge -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
CPPFLAGS = -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
PCFLAGS =
DEFS = -DHAVE_CONFIG_H
LDFLAGS =
LIBS = -lm -lpthread
CXX = g++
CXXFLAGS = -pthread
FEATURES = DPC HDRI Cipher OpenMP
DELEGATES =
==============================================================================
All delegates seem to be not active.
EDIT: I checked the output again. It seems like it doesn't find libpng
-------------------------------------------------------------
checking for libpng >= 1.0.0... no
-------------------------------------------------------------
I checked the installed version and it is 1.6.37-3
When I use ImageMagick outside of the Docker container it works without problems. I'm not sure what the problem is and why it doesn't configure the delegates. Sadly I can't install ImageMagick 7 with apt.
Try adding pkg-config, and possibly also autoconf, to your prerequisite package list. ImageMagick is considerably better at finding and configuring stuff with those helpers, especially the PNG delegate:
RUN apt-get update && apt-get install -y wget && \
apt-get install -y autoconf pkg-config ...
Actually, the Alpine docker image is brilliant for ImageMagick. It is very current, very small, and includes loads of delegates:
docker run --rm -it -v "$(pwd)":/work -w /work alpine:latest
/work # apk add --no-cache imagemagick
...
... output, output, output
... and then around 4 seconds later
...
/work # magick identify -version
Version: ImageMagick 7.1.0-50 beta Q16-HDRI x86_64 20489 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib cairo fontconfig freetype gslib heic jng jpeg jxl lcms ltdl lzma png ps rsvg tiff webp x xml zlib
Compiler: gcc (11.2)
Related
I'm trying to (cross)compile my automake project, which is originally developed for linux/x86_64, within a docker container running on an Apple Macbook with M1 chip.
The docker host (mac) is version 20.10.14, build a224086
The base image is debian:stable, here's the very basic Dockerfile:
FROM debian:stable
USER root
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get -y install build-essential libtool git gperf gengetopt python3-dev \
libsm-dev libjpeg-dev libtiff-dev libxerces-c-dev \
libre2-dev libpcap-dev libsqlite3-dev libsysfs-dev vim
ENTRYPOINT ["/bin/bash"]
gcc -v inside the container gives me:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/10/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.1 20210110 (Debian 10.2.1-6)
All the binaries of the compiler toolchain are a symlink to the actual aarch64-xxx variant, such as:
/usr/bin/gcc-10 -> /usr/bin/aarch64-linux-gnu-gcc-10
/usr/bin/g++-10 -> /usr/bin/aarch64-linux-gnu-g++-10
/usr/bin/ld -> /usr/bin/aarch64-linux-gnu-ld
If I configure my project, it fails with an unknown target:
$ export TARGET=aarch64-linux-gnu
$ export BUILD=aarch64-linux-gnu
$ export HOST=aarch64-linux-gnu
$ ../../src/configure --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
<SNIP>
checking build system type... aarch64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking target system type... aarch64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
<SNIP>
unknown target aarch64-unknown-linux-gnu
Where on earth is the unknown in aarch64-unknown-linux-gnu coming from, when everything in my toolchain says aarch64-linux-gnu?
Is it possible that this is a result of the output generated by one of libtoolize, aclocal, autoconf, autoheader or automake?
Well that's embarrassing. We have a check for the cpu type in our configure.ac and nobody came across aarch64 before, so that check entered the default case every time, which was to exit.
i want to use Imagemagick that runs inside Docker. I created a convert.sh file that runs my Imagemagick with arguments:
convert.sh :
#!/bin/bash
IMAGE=imagemagick
ARGS=$#
exec docker run --rm -i --user="$(id -u):$(id -g)" \
-v "$PWD":/workdir \
$IMAGE /bin/bash -c \
"/usr/bin/convert $ARGS"
Command:
./convert.sh --version
Output:
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org Copyright: © 1999-2017 ImageMagick Studio LLC License: http://www.imagemagick.org/script/license.php Features: Cipher DPC Modules OpenMP Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib
So my imagemagick is accessible.
Inside LocalSetting.php i added:
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/path/to/my/convert.sh";
Sadly this isn't working. I get the error
Error creating the preview image: sh: 1: convert: not found
How can i fix that?
We have an application that requires opencv in a recent version with pkg-config visibility and shared libraries to build. However, the Amazon EC2 AMI instances we are deploying on does not include the yum packages for codecs nor the opencv package.
Other pages describe how to use centOS og rpm packages to get to a working installation. We need a clean install with no yum/rpm cross over.
These steps are most likely one of the shorter paths to the target. Starting directory location is irrelevant as first line ensures a sane (~/build) initial working directory:
cd ~/ && mkdir build && cd build/
sudo yum install git cmake gcc-c++
Build libav for the codecs (the --prefix option is probably not necessary, but this is the tested and working version)
wget https://libav.org/releases/libav-12.3.tar.xz
tar xzf libav-12.3.tar.gz
mkdir libav-12.3-build && cd libav-12.3-build
/home/ec2-user/build/libav-12.3/configure --prefix=/usr --enable-shared --disable-static
make && sudo make install
The amazon default pkg-config thing-a-magic does not look at all standard paths so the next lines symlinks the relevant *.pc files to a location where pkg-config (used by opencv) can find them.
cd /usr/share/pkgconfig
for t in `find /usr -name "libav*.pc"`; do sudo ln -s $t .; done
cd ~/build
The libav shared libraries have to be available to the linker as well
echo /usr/lib/ > libav.conf
sudo mv libav.conf /etc/ld.so.conf.d/
sudo ldconfig
Check the pkg-config libav availability by the command pkg-config --list-all and check that the libavcodec, libavformat, libav... etc. packages are listed.
At this point the opencv library can be built and installed with the default tooling
git clone https://github.com/Itseez/opencv.git
mv opencv opencv.git
cd opencv.git/
git branch -r
git checkout 3.4
cd .. && mkdir opencv && cd opencv
cmake ../opencv.git/ && make && sudo make install
cd ..
The final binary requires the linker path to contain the '''/usr/local/lib64''' path.
echo /usr/local/lib64 > opencv.conf
sudo mv opencv.conf /etc/ld.so.conf.d/
sudo ldconfig
The last trick is to enable pkg-config for opencv as well
cd /usr/share/pkg-config && ln -s `find /usr/local/ -name "opencv.pc"` . && cd ~/build
Check the pkg-config availability by the command
pkg-config --list-all
and check that opencv is listed.
Done
I want to convert images with format jpx and jpf to jpg on Ubuntu 16.
After some research i found out that it is require jp2 delegate. Right now when i executed command
convert -list configure | grep DELEGATES
i got this
bzlib djvu mpeg fftw fontconfig freetype jbig jng jpeg lcms lqr lzma openexr pango png ps rsvg tiff wmf x xml zlib
How can i install jp2 delegate on my system? Or if any other way to convert jpf and jpx to jpg, Please suggest me.
Updated Answer
I am trying to get this working more simply, but only have a limited understanding of Ubuntu Package Managers. Here is my current, simplest, working solution.
Step 1 - Install OpenJPEG2000 and all the build tools
Install v2.1 of OpenJPEG2000 Ubuntu 16 with:
sudo apt-get remove --purge libopenjp2-7 libopenjp2-7-dev
sudo apt-get install libopenjp2-7 libopenjp2-7-dev
sudo apt-get install build-essential pkg-config
Step 2 - set PKG_CONFIG_PATH
That is good and it is the one ImageMagick needs, however, it seems maybe to be in a different place from where ImageMagick expects it. It is not in /usr/lib nor /usr/local/lib, but rather it is here:
/usr/lib/x86_64-linux-gnu/libopenjp2.so.7
/usr/lib/x86_64-linux-gnu/libopenjp2.so
/usr/lib/x86_64-linux-gnu/pkgconfig/libopenjp3d.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/libopenjp2.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/libopenjpip.pc
/usr/lib/x86_64-linux-gnu/openjpeg-2.1
/usr/lib/x86_64-linux-gnu/libopenjp2.so.2.1.0
So, set your PKG_CONFIG_PATH
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/lib/x86_64-linux-gnu/pkgconfig
Step 3 - Install and build ImageMagick from source
cd
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar -xzvf Im*gz
cd Image*[0-9]
./configure
make clean
make -j 8
sudo make install
Original Answer - which works but is cumbersome
Well, this was painful to work out but it works! Ubuntu 16 LTS
First, remove any dead versions of ImageMagick installed via apt-get.
sudo apt-get remove --purge imagemagick
Then, make sure you have all the packages you need to build software with:
sudo apt-get install build-essential cmake pkg-config
Next, install JPEG200 library, version 2.1 or better!!!!
cd
wget https://github.com/uclouvain/openjpeg/archive/v2.1.2.tar.gz
gunzip open*gz
tar -xvf open*tar
cd open*2
mkdir build # Out of source builds are preferred
cd build
cmake --prefix=/usr ..
make clean
make -j 8
sudo make install
Now, install ImageMagick:
cd
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
gunzip Image*gz
tar -xvf *agick*tar
cd ImageMagick-7.0.4-6/
./configure --prefix=/usr
make clean
make -j 8
sudo make install
Now test:
identify -list configure | grep DEL
DELEGATES mpeg jpeg openjp2 ps
I have installed imageMagick but i get a warning loaded PHP Startup. How can i solve this?
[root#vps06 /]# identify -version
Version: ImageMagick 6.8.1-10 2013-07-18 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib freetype jng jp2 jpeg lcms png ps tiff x zli
[root#vps06 /]# php -m | grep imagick
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/imagick.so' - libfftw3.so.3: cannot open shared object file: No such file or directory in Unknown on line 0
You'll need to install the imagick module for PHP. The easiest way would be with the PECL command.
sudo pecl install imagick
You can also manually install this package if you need more control of your local build
curl -O http://pecl.php.net/get/imagick-3.1.0RC2.tgz
tar zxvf imagick-3.1.0RC2.tgz && cd imagick-3.1.0RC2.tgz
phpize
./configure # Add custom build options here
make
sudo make install