Mediawiki with Docker Imagemagick - docker

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?

Related

ImageMagick cannot get file from HTTPS from inside a Docker container

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)

FFMpeg Unknown function in zoompan filter

i'm using ffmpeg with zoompan filter in my local environment whit the following command and it works well:
ffmpeg -y -i "https://my.domain/workspaces/1/a_render_dir/video_spotx.mp4" -i "https://my.domain/workspaces/1/Gallery/travel_6.jpeg" -i "https://my.domain/workspaces/1/Gallery/travel_6.jpeg" -i "https://my.domain/workspaces/1/Gallery/travel_6.jpeg" -i "/usr/app/src/output/video.mp4/text_0.png" -i "/usr/app/src/output/video.mp4/text_1.png" -filter_complex "[0]drawbox=x=0:y=0:w=iw:h=ih:color=00FF00#1:t=fill[padded];[0]format=yuva420p,pad=iw*2:ih*2:color=black#0,zoompan=z='if(lt(it,0),2,if(lte(pzoom,1.0),2,max(1.56,pzoom-0.005789473684210526)))':x=0:y=0:d=1:s=950x540[zp],[padded][zp]overlay=x='if(lt(t,3.04),t*213/3.04,213)':y='if(lt(t,3.04),t*50/3.04,50)':eval=frame[zp_stream],[1:v]scale=237.5:-1 [image1],[2:v]scale=237.5:-1 [image2],[3:v]scale=237.5:-1 [image3],[4:v]scale=475:-1 [image4],[5:v]scale=237.5:-1 [image5],[zp_stream][image1] overlay=95:54:enable='between(t,3,8)' [overlay1],[overlay1][image2] overlay=380:216:enable='between(t,3,8)' [overlay2],[overlay2][image3] overlay=532:54:enable='between(t,5,10)' [overlay3],[overlay3][image4] overlay=475:270:enable='between(t,1,8)' [overlay4],[overlay4][image5] overlay=0:0:enable='between(t,1,8)' [overlay5]" -map "[overlay5]" -pix_fmt yuv420p -map 0:a -c:a copy "/usr/app/src/output/video.mp4/render_video.mp4"
However when i build a docker container and run that command it is not working. The output error is the following:
[Parsed_zoompan_3 # 0x2a08ac0c5140] [Eval # 0x3ec4ec4c9ad0] Unknown function in 'it,0),2,if(lte(pzoom,1.0),2,max(1.56,pzoom-0.005789473684210526)))'
I tried to add a fixed z value to the zoompan filter, and the command works also inside the container, so the issue is on the zoompan syntax.
Here is my docker file
FROM node:16
ENV NODE_ENV=production
RUN apt-get -y update && \
apt-get install -y ffmpeg \
build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
WORKDIR /usr/src/app
COPY . .
RUN npm ci --production --silent
CMD node src/index.js
Problem starts when i switch on new Macbook pro with M1 processor, but i'm not sure it's related, i build the image with the following command:
docker buildx build --platform linux/x86_64 -t render-job .
On my macchine there is ffmpeg 5.0.1 installed, but on docker container the command apt-get install -y ffmpeg installs just the follow wersion:
ffmpeg version 4.1.9-0+deb10u1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
I don't think is relate to the version, because before to build with M1 processor the zoompan filter was working also in the container.
Any help is appreciated.
Thanks.

open cv cmake can't find png and jpeg

I downloaded opencv 3.2,and run:
cmake -D CMAKE_BUILD_TYPE=RELEASE
-D CMAKE_INSTALL_PREFIX=$(python -c "import sys; print(sys.prefix)") -D PYTHON_EXECUTABLE=$(which python)
-D OPENCV_EXTRA_MODULES_PATH=/home/alex/Software/opencv_contrib/modules
-D WITH_OPENGL=ON
-D WITH_JPPEG=ON
-D WITH_PNG=ON
-D WITH_CUDA=ON
-D ENABLE_FAST_MATH=1
-D WITH_CUBLAS=1 ..
under ubuntu 16.04 got:
- Media I/O:
....
-- JPEG: NO
-- WEBP: build (ver 0.3.1)
-- PNG: NO
........
as you can see that both JPEG and PNG give 'NO',and I hava got libjpeg-dev,libgtk2.0-dev and libpng-dev installed.So how to make opencv to support jpeg and png?

ImageMagick convert jpx and jpf to jpg (Ubuntu 16)

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

imageMagick installation problems

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

Resources