forked from yespark/heroku-imagemagick-buildpack
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recompile Imagemagick-7 with newer libs de265 webp heif
- Loading branch information
0 parents
commit 47f86e6
Showing
8 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
heroku-buildpack-imagemagick-heif | ||
================================= | ||
|
||
The rise in popularity and use of HEIF/HEIC(High Efficency Image Format) means your project's image processing also needs to be able to handle this format. | ||
The current default version of imagemagick installed on heroku:20 dynos is a version 6.xx and does not support processing heic image files. | ||
|
||
This [Heroku buildpack](https://devcenter.heroku.com/articles/buildpacks) vendors a version of ImageMagick with **WEBP and HEIF support** binaries into your project. | ||
|
||
This one works was built for [**Heroku stack 20**](https://devcenter.heroku.com/articles/stack). | ||
|
||
The tar file in the [/build folder](./build) currently contains: | ||
|
||
Version: ImageMagick 7.0.10-53 | ||
|
||
You will need to build a new binary if you want to use a newer or different version. To build a new binary see [How to Build a New Binary](#how-to-build-a-new-binary) | ||
|
||
# Usage | ||
## Step 1 : Adding the buildpack | ||
|
||
From your projects "Settings" tab add this buildpack to your app in the 1st position: | ||
|
||
```bash | ||
https://github.com/yespark/heroku-imagemagick-buildpack | ||
``` | ||
**NOTE:** __To ensure the newer version of imagemagick is found in the $PATH and installed first make sure this buildpack is added to the top of the buildpack list or at "index 1"._ | ||
|
||
|
||
## Step 2 : Clear the cache(__Not Sure if this is necessary__) | ||
Since the installation is cached you might want to clean it out due to config changes. | ||
|
||
```bash | ||
heroku plugins:install heroku-repo | ||
heroku repo:purge_cache -app HEROKU_APP_NAME | ||
``` | ||
|
||
# How to Build a New Binary (if you want to make somes changes) | ||
|
||
The binary in this repo was built in a heroku:20 docker image running in a local dev environment. | ||
However, there is a script called [**build.sh**](./build.sh) made to build a tar file through docker easily, it will be copied to the `build` directory. Then you should commit this changes to your git, and adjust the buildpack url previously mentionned just above. | ||
|
||
## Prerequisites | ||
|
||
- Docker installed and running in local dev environment. [Get Docker](https://docs.docker.com/get-docker/) | ||
## Credits | ||
- https://medium.com/@eplt/5-minutes-to-install-imagemagick-with-heic-support-on-ubuntu-18-04-digitalocean-fe2d09dcef1 | ||
- https://github.com/brandoncc/heroku-buildpack-vips | ||
- https://github.com/steeple-dev/heroku-buildpack-imagemagick | ||
- https://github.com/retailzipline/heroku-buildpack-imagemagick-heif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bash | ||
# bin/compile <build-dir> <cache-dir> | ||
|
||
set -e | ||
|
||
BUILD_DIR=$1 | ||
CACHE_DIR=$2 | ||
ENV_DIR=$3 | ||
|
||
BIN_DIR=$(cd "$(dirname "$0")"; pwd) | ||
ROOT_DIR=$(dirname "$BIN_DIR") | ||
|
||
function vendor() { | ||
local binary="$1" | ||
local path="$2" | ||
mkdir -p $path | ||
tar -xj -f $binary -C $path | ||
if [ -d "$path/bin" ]; then | ||
export PATH="$path/bin:$PATH" | ||
fi | ||
if [ -d "$path/lib/pkgconfig" ]; then | ||
export PKG_CONFIG_PATH="$path/lib/pkgconfig:$PKG_CONFIG_PATH" | ||
fi | ||
export CPPPATH="$path/include:$CPPPATH" | ||
export CPATH="$path/include:$CPATH" | ||
export LIBRARY_PATH="$path/lib:$LIBRARY_PATH" | ||
export LD_LIBRARY_PATH="$path/lib:$LD_LIBRARY_PATH" | ||
} | ||
|
||
vendor "$ROOT_DIR/build/imagemagick.tar.bz2" "$BUILD_DIR/vendor/imagemagick" | ||
|
||
cat <<EOF > export | ||
export PATH="/app/bin:$PATH:\$PATH" | ||
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:$LD_LIBRARY_PATH" | ||
export LIBRARY_PATH="\$LIBRARY_PATH:$LIBRARY_PATH" | ||
export PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:$PKG_CONFIG_PATH" | ||
export CPPPATH="\$CPPPATH:$CPPPATH" | ||
export CPATH="\$CPATH:$CPATH" | ||
EOF | ||
|
||
mkdir -p $BUILD_DIR/.profile.d | ||
cat <<EOF > $BUILD_DIR/.profile.d/imagemagick.sh | ||
export PATH="/app/bin:${PATH//$BUILD_DIR//app}:\$PATH" | ||
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:${LD_LIBRARY_PATH//$BUILD_DIR//app}" | ||
export LIBRARY_PATH="\$LIBRARY_PATH:${LIBRARY_PATH//$BUILD_DIR//app}" | ||
export PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:${PKG_CONFIG_PATH//$BUILD_DIR//app}" | ||
export CPPPATH="\$CPPPATH:${CPPPATH//$BUILD_DIR//app}" | ||
export CPATH="\$CPATH:${CPATH//$BUILD_DIR//app}" | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env bash | ||
echo "ImageMagick" && exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env bash | ||
echo "--- {}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
docker build --no-cache --pull -t heroku-imagemagick container | ||
mkdir -p build | ||
docker run --rm -t -v $PWD/build:/data heroku-imagemagick sh -c 'cp -f /usr/src/imagemagick/build/*.tar.bz2 /data/' |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
FROM heroku/heroku:20-build | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
ARG VERSION_LIBDE265=1.0.8 | ||
ARG VERSION_LIBHEIF=1.10.0 | ||
ARG VERSION_LIBWEBP=1.1.0 | ||
|
||
ARG VERSION_IMAGEMAGICK=7.0.10-53 | ||
|
||
RUN apt-get -yq update \ | ||
# Install install the latest libde265 library | ||
&& curl -sSL --retry 3 https://github.com/strukturag/libde265/releases/download/v$VERSION_LIBDE265/libde265-$VERSION_LIBDE265.tar.gz | tar zx \ | ||
&& cd libde265-$VERSION_LIBDE265 \ | ||
&& ./autogen.sh \ | ||
&& ./configure \ | ||
&& make -j$(nproc) \ | ||
&& make install \ | ||
# Install install the latest libheif library | ||
&& curl -sSL --retry 3 https://github.com/strukturag/libheif/releases/download/v$VERSION_LIBHEIF/libheif-$VERSION_LIBHEIF.tar.gz | tar zx \ | ||
&& cd libheif-$VERSION_LIBHEIF \ | ||
&& ./autogen.sh \ | ||
&& ./configure \ | ||
&& make -j$(nproc) \ | ||
&& make install \ | ||
# Install install the latest libwebp library | ||
&& curl -sSL --retry 3 http://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-$VERSION_LIBWEBP.tar.gz | tar zx \ | ||
&& cd libwebp-$VERSION_LIBWEBP \ | ||
&& ./autogen.sh \ | ||
&& ./configure \ | ||
&& make -j$(nproc) \ | ||
&& make install \ | ||
# Get, configure and install imagemagick | ||
&& curl -sSL https://imagemagick.org/download/releases/ImageMagick-$VERSION_IMAGEMAGICK.tar.bz2 | tar jx \ | ||
&& cd ImageMagick-$VERSION_IMAGEMAGICK \ | ||
&& ./configure --prefix=/usr/src/imagemagick --with-heic=yes --with-webp=yes --with-openexr=no --with-x=no --disable-docs \ | ||
&& make -j$(nproc) \ | ||
&& make install \ | ||
# Copy shared libraries just compiled | ||
&& cp /usr/local/lib/libde265.so.0 /usr/src/imagemagick/lib \ | ||
&& cp /usr/local/lib/libheif.so.1 /usr/src/imagemagick/lib \ | ||
&& cp /usr/local/lib/libwebp.so.7 /usr/src/imagemagick/lib \ | ||
# Clean up the build and get ready for packaging | ||
&& cd /usr/src/imagemagick \ | ||
&& strip lib/*.a lib/lib*.so* \ | ||
# Wrap it up with a bow (compress the binary) | ||
&& rm -rf build \ | ||
&& mkdir build \ | ||
&& tar cjf /usr/src/imagemagick/build/imagemagick.tar.bz2 bin include lib |