|
| 1 | +# Image processing |
| 2 | + |
| 3 | +Material for MkDocs depends on several libraries to allow for image processing |
| 4 | +as part of the build pipline, including [social cards] and [image optimization]. |
| 5 | +For this reason, a few external libraries must be installed on the host system. |
| 6 | +This section explains how to install them. |
| 7 | + |
| 8 | + [social cards]: ../setting-up-social-cards.md |
| 9 | + [image optimization]: ../building-an-optimized-site.md |
| 10 | + |
| 11 | +## Dependencies |
| 12 | + |
| 13 | +### Cairo Graphics |
| 14 | + |
| 15 | +[Cairo Graphics] is a graphics library and dependency of [Pillow], which |
| 16 | +Material for MkDocs makes use of for generating [social cards] and performing |
| 17 | +[image optimization]. See the following section which explains how to install |
| 18 | +[Cairo Graphics] and its dependencies on your system: |
| 19 | + |
| 20 | +=== ":material-apple: macOS" |
| 21 | + |
| 22 | + Make sure [Homebrew] is installed, which is a modern package manager for |
| 23 | + macOS. Next, use the following command to install all necessary |
| 24 | + dependencies: |
| 25 | + |
| 26 | + ``` |
| 27 | + brew install cairo freetype libffi libjpeg libpng zlib |
| 28 | + ``` |
| 29 | + |
| 30 | +=== ":fontawesome-brands-windows: Windows" |
| 31 | + |
| 32 | + As stated in the [installation guide], the easiest way to get up and running |
| 33 | + with the [Cairo Graphics] library on Windows is by installing [GTK+], since |
| 34 | + it has Cairo as a dependency. You can also download and install a |
| 35 | + precompiled [GTK runtime]. |
| 36 | + |
| 37 | +=== ":material-linux: Linux" |
| 38 | + |
| 39 | + There are several package managers for Linux with varying availability per |
| 40 | + distribution. The [installation guide] explains how to install the [Cairo |
| 41 | + Graphics] library for your distribution: |
| 42 | + |
| 43 | + === ":material-ubuntu: Ubuntu" |
| 44 | + |
| 45 | + ``` |
| 46 | + apt-get install libcairo2-dev libfreetype6-dev libffi-dev libjpeg-dev libpng-dev libz-dev |
| 47 | + ``` |
| 48 | + |
| 49 | + === ":material-fedora: Fedora" |
| 50 | + |
| 51 | + ``` |
| 52 | + yum install cairo-devel freetype-devel libffi-devel libjpeg-devel libpng-devel zlib-devel |
| 53 | + ``` |
| 54 | + |
| 55 | + === ":fontawesome-brands-suse: openSUSE" |
| 56 | + |
| 57 | + ``` |
| 58 | + zypper install cairo-devel freetype-devel libffi-devel libjpeg-devel libpng-devel zlib-devel |
| 59 | + ``` |
| 60 | + |
| 61 | +The following environments come with a preinstalled version of [Cairo Graphics]: |
| 62 | + |
| 63 | +- [x] No installation needed in [Docker image] |
| 64 | +- [x] No installation needed in [GitHub Actions] (Ubuntu) |
| 65 | + |
| 66 | + [Cairo Graphics]: https://www.cairographics.org/ |
| 67 | + [Pillow]: https://pillow.readthedocs.io/ |
| 68 | + [CairoSVG]: https://cairosvg.org/ |
| 69 | + [Homebrew]: https://brew.sh/ |
| 70 | + [installation guide]: https://www.cairographics.org/download/ |
| 71 | + [GTK+]: https://www.gtk.org/docs/installations/windows/ |
| 72 | + [GTK runtime]: https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases |
| 73 | + [Docker image]: https://hub.docker.com/r/squidfunk/mkdocs-material/ |
| 74 | + [GitHub Actions]: ../../publishing-your-site.md#with-github-actions |
| 75 | + |
| 76 | +### pngquant |
| 77 | + |
| 78 | +[pngquant] is an excellent library for lossy PNG compression, and a direct |
| 79 | +dependency of the [built-in optimize plugin]. See the following section which |
| 80 | +explains how to install [pngquant] system: |
| 81 | + |
| 82 | +=== ":material-apple: macOS" |
| 83 | + |
| 84 | + Make sure [Homebrew] is installed, which is a modern package manager for |
| 85 | + macOS. Next, use the following command to install all necessary |
| 86 | + dependencies: |
| 87 | + |
| 88 | + ``` |
| 89 | + brew install pngquant |
| 90 | + ``` |
| 91 | + |
| 92 | +=== ":fontawesome-brands-windows: Windows" |
| 93 | + |
| 94 | + Installing [pngquant] on Windows is a little more involved. The |
| 95 | + [pngquant-winbuild] repository contains a guide on how to set up an |
| 96 | + environment for building [pngquant] on Windows. |
| 97 | + |
| 98 | +=== ":material-linux: Linux" |
| 99 | + |
| 100 | + All popular Linux distributions, regardless of package manager, should |
| 101 | + allow to install [pngquant] with the bundled package manager. For example, |
| 102 | + on Ubuntu, [pngquant] can be installed with: |
| 103 | + |
| 104 | + ``` |
| 105 | + apt-get install pngquant |
| 106 | + ``` |
| 107 | + |
| 108 | + The same is true for `yum` and `zypper`. |
| 109 | + |
| 110 | + [pngquant]: https://pngquant.org/ |
| 111 | + [built-in optimize plugin]: ../building-an-optimized-site.md#built-in-optimize-plugin |
| 112 | + [pngquant-winbuild]: https://github.com/jibsen/pngquant-winbuild |
0 commit comments