dooman87 / imagemagick-docker

Running the latest version of imagemagick inside container
https://hub.docker.com/r/dpokidov/imagemagick
MIT License
95 stars 25 forks source link

Fontconfig and freetype support #13

Closed creemama closed 3 years ago

creemama commented 3 years ago

Before this commit, when running convert commands overlaying text on an image, ImageMagick would output the following warning:

convert: delegate library support not built-in '...' (Freetype) @ warning/annotate.c/RenderFreetype/1873

Even though text would render on the output image, the text looked pixelated. Adding fontconfig and freetype to ImageMagick fixes this.

See the following link for more info: https://web.archive.org/web/20210621064448/https://legacy.imagemagick.org/discourse-server/viewtopic.php?t=21070

The following is a comparison of the output from the existing dpokidov/imagemagick Docker images and images built from this commit:

OUTPUT FROM EXISTING dpokidov/imagemagick DOCKER IMAGES:

$ docker run -it --rm dpokidov/imagemagick:latest -version
Version: ImageMagick 7.0.11-13 Q16 x86_64 2021-05-16 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): heic jbig jng jpeg lzma png tiff webp xml zlib

$ docker run --rm -v $(pwd):/imgs dpokidov/imagemagick:latest /imgs/test.jpg -antialias -font Helvetica-Bold -pointsize 20 -gravity Southeast -annotate +15+15 'TEST' /imgs/test-text.jpg
convert: delegate library support not built-in '/usr/share/fonts/type1/gsfonts/n019004l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1873.
convert: delegate library support not built-in '/usr/share/fonts/type1/gsfonts/n019004l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1873.

$ docker run -it --rm dpokidov/imagemagick:latest-stretch -version
Version: ImageMagick 7.0.11-13 Q16 x86_64 2021-05-16 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): jng jpeg png webp xml zlib

$ $ docker run --rm -v $(pwd):/imgs dpokidov/imagemagick:latest-stretch /imgs/test.jpg -antialias -font Helvetica-Bold -pointsize 20 -gravity Southeast -annotate +15+15 'TEST' /imgs/test-text.jpg
convert: delegate library support not built-in '/usr/share/fonts/type1/gsfonts/n019004l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1873.
convert: delegate library support not built-in '/usr/share/fonts/type1/gsfonts/n019004l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1873.

$ docker run -it --rm dpokidov/imagemagick:latest-fedora27 -version
Version: ImageMagick 7.0.11-13 Q16 x86_64 2021-05-16 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): jng jpeg lcms lzma png raw tiff webp xml zlib

$ docker run --rm -v $(pwd):/imgs dpokidov/imagemagick:latest-fedora27 /imgs/test.jpg -antialias -font NimbusRoman-Bold -pointsize 20 -gravity Southeast -annotate +15+15 'TEST' /imgs/test-text.jpg
convert: unable to read font `NimbusRoman-Bold' @ warning/annotate.c/RenderType/971.
convert: delegate library support not built-in 'NimbusRoman-Bold' (Freetype) @ warning/annotate.c/RenderFreetype/1873.
convert: unable to read font `NimbusRoman-Bold' @ warning/annotate.c/RenderType/971.
convert: delegate library support not built-in 'NimbusRoman-Bold' (Freetype) @ warning/annotate.c/RenderFreetype/1873.

OUTPUT FROM DOCKER IMAGES BUILT FROM THIS COMMIT:

$ docker run -it --rm im-fedora27:latest -version
Version: ImageMagick 7.0.11-13 Q16 x86_64 2021-05-16 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): bzlib fontconfig freetype jng jpeg lcms lzma png raw tiff webp xml zlib

$ docker run --rm -v $(pwd):/imgs im-fedora27 /imgs/test.jpg -antialias -font NimbusRoman-Bold -pointsize 20 -gravity Southeast -annotate +15+15 'TEST' /imgs/test-text.jpg

$ docker run -it --rm im-stretch:latest -version
Version: ImageMagick 7.0.11-13 Q16 x86_64 2021-05-16 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): fontconfig freetype jbig jng jpeg lzma png tiff webp xml zlib

$ docker run --rm -v $(pwd):/imgs im-stretch /imgs/test.jpg -antialias -font Helvetica-Bold -pointsize 20 -gravity Southeast -annotate +15+15 'TEST' /imgs/test-text.jpg

$ docker run -it --rm im-buster:latest -version
Version: ImageMagick 7.0.11-13 Q16 x86_64 2021-05-16 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): fontconfig freetype heic jbig jng jpeg lzma png tiff webp xml zlib

$ docker run --rm -v $(pwd):/imgs im-buster /imgs/test.jpg -antialias -font Helvetica-Bold -pointsize 20 -gravity Southeast -annotate +15+15 'TEST' /imgs/test-text.jpg
dooman87 commented 3 years ago

LGTM! Thanks a lot for your contribution!