Skip to content

Instantly share code, notes, and snippets.

@dotysan
Last active September 14, 2025 16:59
Show Gist options
  • Select an option

  • Save dotysan/6ffed2dc436c636f61900075ae6d165f to your computer and use it in GitHub Desktop.

Select an option

Save dotysan/6ffed2dc436c636f61900075ae6d165f to your computer and use it in GitHub Desktop.
build static libheic in a docker container & install in user home

build static libheic in a docker container & install in user home

This installs minimalist heif-info & heif-convert that can only decode HEIC and encode JPEG.

Installation

  • ./install-heic.sh
FROM alpine:latest as build
ARG HEV=1.20.2
ARG TB=https://github.com/strukturag/libheif/releases/download/v$HEV/libheif-$HEV.tar.gz
RUN until \
wget --no-verbose --output-document=- $TB |tar -xzf- \
; do sleep 1 ; done
RUN apk add --no-cache \
cmake \
g++ \
libde265-dev \
libde265-static \
libjpeg-turbo-dev \
libjpeg-turbo-static \
make \
&& :
WORKDIR /libheif-$HEV
RUN cmake -B build \
-DCMAKE_EXE_LINKER_FLAGS="-static" \
-DLIBDE265_LIBRARY=/usr/lib/libde265.a \
-DJPEG_LIBRARY=/usr/lib/libjpeg.a \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DENABLE_PLUGIN_LOADING=OFF \
-DWITH_JPEG_ENCODER=ON \
-DWITH_LIBSHARPYUV=OFF \
-DWITH_X265=OFF \
-DWITH_OpenH264_DECODER=OFF \
-DWITH_AOM_DECODER=OFF \
-DWITH_AOM_ENCODER=OFF \
-DWITH_GDK_PIXBUF=OFF \
-DCMAKE_DISABLE_FIND_PACKAGE_TIFF=TRUE \
-DCMAKE_DISABLE_FIND_PACKAGE_PNG=TRUE \
-DCMAKE_DISABLE_FIND_PACKAGE_SDL2=TRUE \
-DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=TRUE \
-DCMAKE_BUILD_TYPE=Release \
&& \
cmake --build build -j \
&& \
cmake --install build
FROM scratch AS heic-artifacts
COPY --from=build /usr/local /
#! /usr/bin/env bash
#
# build static libheic in a docker container & install in user home
#
set -e
set -u
set -x
main() {
if ! hash docker
then
"ERROR: Need docker to build."
exit 1
fi >&2
docker buildx build --progress=plain --tag build-heic \
--output type=local,dest=./artifacts \
.
cp -fal artifacts/bin/heif-* ~/bin/
}
main
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment