0

Running macOS, python3.10.8

Currently attempting my first app transition to a docker file. During operation of my app, i am returned the following errors:

convert-im6.q16: unable to read font `Avenir-Next-Condensed-Bold' @ warning/annotate.c/RenderType/949.

convert-im6.q16: unable to read font `Avenir-Next-Condensed-Bold' @ error/annotate.c/RenderFreetype/1396.

convert-im6.q16: no images defined `PNG32:/tmp/tmpjvur568d.png' @ error/convert.c/ConvertImageCommand/3229.

I fail to understand why imagemagick cant read the stock font which is pre-installed in moviepy, and then further why it cannot read images. For reference, I am passing a video (2-3min in length), along with subtitles and an audio track into moviepy.

I have put in place a policy.xml file for imagemagick which allows the library to read/write files of the size i need. (refer here: https://stackoverflow.com/questions/52703123/override-default-imagemagick-policy-xml)

I have redirected the imagemagick library using the following dockerfile command ENV LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"

I am running the following install commands for libraries within dockerfile

RUN apt-get -y update
RUN apt-get update && apt-get install -y \
    libsm6 \
    libxext6 \
    libxrender-dev \
    fontconfig

RUN apt-get update && apt-get install -y ffmpeg
RUN apt-get update && apt-get install -y imagemagick

I have ffmpeg working in the docker container and producing and cutting audio/video files as needed, which means the filepaths are routed correctly i believe.

I have attempted creating this docker image using python3.10 and python3.8 and receive the same errors both times.

I am coming to a loss of what to do next. Any Advice forward is appreciated.

edit:

identify -list configure

Returns:

    Path: /opt/homebrew/Cellar/imagemagick/7.1.0-61/lib/ImageMagick//config-Q16HDRI/configure.xml

Name                  Value
-------------------------------------------------------------------------------
CC                    clang
CFLAGS                 -I/opt/homebrew/Cellar/webp/1.3.0/include -I/opt/homebrew/Cellar/webp/1.3.0/include/webp -I/opt/homebrew/Cellar/webp/1.3.0/include -I/opt/homebrew/Cellar/webp/1.3.0/include/webp -I/opt/homebrew/Cellar/libtiff/4.4.0_1/include -I/opt/homebrew/Cellar/little-cms2/2.14/include -I/opt/homebrew/Cellar/libraw/0.21.1/include/libraw -I/opt/homebrew/Cellar/libraw/0.21.1/include -I/opt/homebrew/Cellar/libpng/1.6.39/include/libpng16 -pthread -I/opt/homebrew/Cellar/imath/3.1.6/include -I/opt/homebrew/Cellar/imath/3.1.6/include/Imath -I/opt/homebrew/Cellar/openexr/3.1.5/include -I/opt/homebrew/Cellar/openexr/3.1.5/include/OpenEXR -I/opt/homebrew/Cellar/xz/5.4.1/include -I/opt/homebrew/Cellar/pcre2/10.42/include -I/opt/homebrew/Cellar/glib/2.74.5/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.74.5/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/liblqr/0.4.2_1/include/lqr-1 -I/opt/homebrew/Cellar/openjpeg/2.5.0/include/openjpeg-2.5 -I/opt/homebrew/Cellar/little-cms2/2.14/include -DHWY_SHARED_DEFINE -I/opt/homebrew/Cellar/brotli/1.0.9/include -I/opt/homebrew/Cellar/highway/1.0.3/include -I/opt/homebrew/Cellar/jpeg-xl/0.8.1/include -I/opt/homebrew/Cellar/libvmaf/2.3.1/include -I/opt/homebrew/Cellar/libvmaf/2.3.1/include/libvmaf -I/opt/homebrew/Cellar/aom/3.5.0_2/include -I/opt/homebrew/Cellar/libde265/1.0.11/include -I/opt/homebrew/Cellar/x265/3.5/include -I/opt/homebrew/Cellar/libheif/1.14.2_1/include -I/opt/homebrew/opt/freetype/include/freetype2 -I/opt/homebrew/opt/freetype/include/freetype2 -I/opt/homebrew/Cellar/fontconfig/2.14.2/include   -Xpreprocessor -fopenmp -Wall -g -O2 -fexceptions -D_FORTIFY_SOURCE=0 -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
CODER_PATH            /opt/homebrew/Cellar/imagemagick/7.1.0-61/lib/ImageMagick/modules-Q16HDRI/coders
CONFIGURE             ./configure  '--disable-debug' '--disable-dependency-tracking' '--prefix=/opt/homebrew/Cellar/imagemagick/7.1.0-61' '--libdir=/opt/homebrew/Cellar/imagemagick/7.1.0-61/lib' '--enable-osx-universal-binary=no' '--disable-silent-rules' '--disable-opencl' '--enable-shared' '--enable-static' '--with-freetype=yes' '--with-gvc=no' '--with-modules' '--with-openjp2' '--with-openexr' '--with-webp=yes' '--with-heic=yes' '--with-raw=yes' '--with-gslib' '--with-gs-font-dir=/opt/homebrew/share/ghostscript/fonts' '--with-lqr' '--without-djvu' '--without-fftw' '--without-pango' '--without-wmf' '--enable-openmp' '--without-x' 'ac_cv_prog_c_openmp=-Xpreprocessor -fopenmp' 'ac_cv_prog_cxx_openmp=-Xpreprocessor -fopenmp' 'LDFLAGS=-lomp -lz' 'CC=clang' 'PKG_CONFIG_PATH=/opt/homebrew/opt/libpng/lib/pkgconfig:/opt/homebrew/opt/freetype/lib/pkgconfig:/opt/homebrew/opt/fontconfig/lib/pkgconfig:/opt/homebrew/opt/jbig2dec/lib/pkgconfig:/opt/homebrew/opt/jpeg-turbo/lib/pkgconfig:/opt/homebrew/opt/libidn/lib/pkgconfig:/opt/homebrew/opt/lz4/lib/pkgconfig:/opt/homebrew/opt/xz/lib/pkgconfig:/opt/homebrew/opt/zstd/lib/pkgconfig:/opt/homebrew/opt/libtiff/lib/pkgconfig:/opt/homebrew/opt/little-cms2/lib/pkgconfig:/opt/homebrew/opt/openjpeg/lib/pkgconfig:/opt/homebrew/opt/brotli/lib/pkgconfig:/opt/homebrew/opt/highway/lib/pkgconfig:/opt/homebrew/opt/imath/lib/pkgconfig:/opt/homebrew/opt/openexr/lib/pkgconfig:/opt/homebrew/opt/webp/lib/pkgconfig:/opt/homebrew/opt/jpeg-xl/lib/pkgconfig:/opt/homebrew/opt/libvmaf/lib/pkgconfig:/opt/homebrew/opt/aom/lib/pkgconfig:/opt/homebrew/opt/libde265/lib/pkgconfig:/opt/homebrew/opt/pcre2/lib/pkgconfig:/opt/homebrew/opt/glib/lib/pkgconfig:/opt/homebrew/opt/x265/lib/pkgconfig:/opt/homebrew/opt/libheif/lib/pkgconfig:/opt/homebrew/opt/liblqr/lib/pkgconfig:/opt/homebrew/opt/jasper/lib/pkgconfig:/opt/homebrew/opt/libraw/lib/pkgconfig:/opt/homebrew/opt/shared-mime-info/share/pkgconfig' 'PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/12' 'CXX=clang++'
CONFIGURE_PATH        /opt/homebrew/Cellar/imagemagick/7.1.0-61/etc/ImageMagick-7/
COPYRIGHT             Copyright (C) 1999 ImageMagick Studio LLC
CPPFLAGS              -I/opt/homebrew/Cellar/imagemagick/7.1.0-61/include/ImageMagick-7
CXX                   clang++ -std=gnu++11 -std=gnu++11
CXXFLAGS               -pthread
DEFS                  -DHAVE_CONFIG_H
DELEGATES             bzlib fontconfig freetype gslib heic jng jpeg jxl lcms lqr lzma openexr openjp2 png ps raw tiff webp xml zlib zstd
DISTCHECK_CONFIG_FLAGS 'CC=clang' 'CXX=clang++' 'LDFLAGS=-lomp -lz'  --disable-deprecated  --with-quantum-depth=16  --with-jemalloc=no  --with-umem=no  --with-autotrace=no  --with-dps=no  --with-fftw=no  --with-flif=no  --with-fpx=no  --with-djvu=no  --with-fontpath=  --with-gs-font-dir=/opt/homebrew/share/ghostscript/fonts  --with-gvc=no  --with-pango=no  --with-rsvg=no  --with-wmf=no  --with-perl=no 
DOCUMENTATION_PATH    /opt/homebrew/Cellar/imagemagick/7.1.0-61/share/doc/ImageMagick-7
EXEC-PREFIX           /opt/homebrew/Cellar/imagemagick/7.1.0-61
EXECUTABLE_PATH       /opt/homebrew/Cellar/imagemagick/7.1.0-61/bin
FEATURES              DPC HDRI Cipher OpenMP Modules
FILTER_PATH           /opt/homebrew/Cellar/imagemagick/7.1.0-61/lib/ImageMagick/modules-Q16HDRI/filters
GIT_REVISION          20866
HOST                  aarch64-apple-darwin21.6.0
INCLUDE_PATH          /opt/homebrew/Cellar/imagemagick/7.1.0-61/include/ImageMagick-7
LDFLAGS               -L/opt/homebrew/Cellar/imagemagick/7.1.0-61/lib -lomp -lz
LIB_VERSION           0x710
LIB_VERSION_NUMBER    7,1,0,61
LIBRARY_PATH          /opt/homebrew/Cellar/imagemagick/7.1.0-61/lib/ImageMagick
LIBS                   -L/opt/homebrew/Cellar/little-cms2/2.14/lib -llcms2 -L/opt/homebrew/opt/freetype/lib -lfreetype  -L/opt/homebrew/Cellar/glib/2.74.5/lib -L/opt/homebrew/opt/gettext/lib -llqr-1 -lglib-2.0 -lintl  -lxml2  -L/opt/homebrew/opt/freetype/lib -L/opt/homebrew/Cellar/fontconfig/2.14.2/lib -lfontconfig -lfreetype     -lbz2 -lz   -lltdl  -lm    -lpthread  
NAME                  ImageMagick
PCFLAGS               -Xpreprocessor -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
PREFIX                /opt/homebrew/Cellar/imagemagick/7.1.0-61
QuantumDepth          16
RELEASE_DATE          2023-02-05
SHARE_PATH            /opt/homebrew/Cellar/imagemagick/7.1.0-61/share/ImageMagick-7
SHAREARCH_PATH        /opt/homebrew/Cellar/imagemagick/7.1.0-61/lib/ImageMagick/config-Q16HDRI
TARGET_CPU            aarch64
TARGET_OS             darwin21.6.0
TARGET_VENDOR         apple
VERSION               7.1.0
WEBSITE               https://imagemagick.org

Path: [built-in]

Name                  Value
-------------------------------------------------------------------------------
DELEGATES             bzlib fontconfig freetype gslib heic jng jp2 jpeg jxl lcms lqr ltdl lzma openexr png ps raw tiff webp xml zlib
FEATURES              Cipher DPC HDRI Modules OpenMP(5.0) 
MAGICK_TEMPORARY_PATH /var/folders/d5/lhm1cjcx2dgdvn6m9whcbdfm0000gn/T
NAME                  ImageMagick
QuantumDepth          Q16
  • Please click [edit] and add the `convert` command you are using. Also please add the output from `identify -list configure` – Mark Setchell Feb 21 '23 at 07:42
  • Revised to add output from `identify -list configure`, also i dont currently have a `convert` command in my docker file, nor am i running one when building / running the image. @MarkSetchell – Gablo Ficazzo Feb 21 '23 at 15:14
  • Your docker host is a Mac. Your docker image is Ubuntu/Debian. You are trying to run `moviepy` within your Ubuntu container, not on your Mac. So you need to run the commands I suggested in the Ubuntu container, not directly on your Mac. – Mark Setchell Feb 21 '23 at 18:00
  • @MarkSetchell, I resolved the issue, but am curious as to what you would be looking for with the two commands you suggested, so i can learn for future use. What details in the outputs would inform you that something was incorrect? – Gablo Ficazzo Feb 21 '23 at 20:47
  • It would have enabled me to check the version, and the support for fonts and how it was built - quite a list of points really. Glad you got it solved. – Mark Setchell Feb 21 '23 at 21:42
  • Okay i will keep that in mind in the future. I appreciate your help. @MarkSetchell – Gablo Ficazzo Feb 21 '23 at 22:56

1 Answers1

0

I ended up resolving this issue by creating a copy of my desired font off of the local disk, and transferring it to the fonts folder inside of the container.

Below i'll attach the Dockerfile lines to install ImageMagick, modify the policy.xml file in ImageMagick to allow for editing, transferring the font from my local disk to the container fonts folder, and finally updating the cache to show the new fonts.

## ImageMagicK Installation ##
RUN mkdir -p /tmp/distr && \
    cd /tmp/distr && \
    wget https://download.imagemagick.org/ImageMagick/download/releases/ImageMagick-7.0.11-2.tar.xz && \
    tar xvf ImageMagick-7.0.11-2.tar.xz && \
    cd ImageMagick-7.0.11-2 && \
    ./configure --enable-shared=yes --disable-static --without-perl && \
    make && \
    make install && \
    ldconfig /usr/local/lib && \
    cd /tmp && \
    rm -rf distr

# Create a policy file for ImageMagick to be able to write files
COPY policy.xml /etc/ImageMagick-6/policy.xml

# Copy Avenir font files to image
COPY avenir-next-condensed.ttc /usr/share/fonts/truetype/custom/

# Run fc-cache to update font cache
RUN fc-cache -f -v