Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[desktop] Replace ImageMagick with vips

Manav Rathi892f1305803d
diff --git a/desktop/CHANGELOG.md b/desktop/CHANGELOG.md
index 7633d9a951..dd734189af 100644
--- a/desktop/CHANGELOG.md
+++ b/desktop/CHANGELOG.md
@@ -2,6 +2,7 @@
## v1.7.9 (Unreleased)
+- Faster and more stable thumbnail generation.
- .
## v1.7.8
diff --git a/desktop/docs/dependencies.md b/desktop/docs/dependencies.md
index 62a9a3eae0..d5d58e772a 100644
--- a/desktop/docs/dependencies.md
+++ b/desktop/docs/dependencies.md
@@ -111,12 +111,10 @@ For video conversions and metadata extraction, we use ffmpeg. To bundle a
> ffmpeg binary and using the wasm one (that our renderer process already has).
> Which is why we bundle it to speed up operations on the desktop app.
-TODO: Cleanup im - update this
-
-On Linux and Windows, we use ImageMagick for thumbnail generation and JPEG
-conversion of unpreviewable images. A static OS/architecture specific binary of
-this is bundled in our extra resources (`build`) folder by `scripts/magick.sh`
-and/or `scripts/beforeBuild.js`. See "[Note: ImageMagick]" for more details.
+On Linux and Windows, we use `vips` for thumbnail generation and JPEG conversion
+of unpreviewable images. A static OS/architecture specific binary of this is
+bundled in our extra resources (`build`) folder by `scripts/vips.sh` and/or
+`scripts/beforeBuild.js`. See "[Note: vips]" for more details.
On macOS, we use the `sips` CLI tool for these tasks, but that is already
available on the host machine, and is not bundled with our app.
diff --git a/desktop/scripts/beforeBuild.js b/desktop/scripts/beforeBuild.js
index d6cdeb0e67..10aa558dc2 100755
--- a/desktop/scripts/beforeBuild.js
+++ b/desktop/scripts/beforeBuild.js
@@ -37,7 +37,7 @@ module.exports = async (context) => {
// https://github.com/electron-userland/electron-builder/blob/master/packages/builder-util/src/arch.ts#L9
// https://nodejs.org/api/process.html#processarch
if (arch == process.arch) {
- // `magick.js` would've already downloaded the file, nothing to do.
+ // `vips.js` would've already downloaded the file, nothing to do.
return true;
}
diff --git a/desktop/scripts/magick.yml b/desktop/scripts/magick.yml
deleted file mode 100644
index aa49e14021..0000000000
--- a/desktop/scripts/magick.yml
+++ /dev/null
@@ -1,127 +0,0 @@
-on:
- workflow_dispatch:
- push: # Push a tag to build and create a draft release
- tags:
- - "*"
-
-name: binaries-for-ente
-jobs:
- create_magick_binary:
- name: Create magick binary (Linux)
- runs-on: ${{ matrix.os }}
-
- strategy:
- matrix:
- os: [ubuntu-24.04, ubuntu-24.04-arm]
- compiler: [gcc]
- include:
- - os: ubuntu-24.04
- arch: x86_64
- - os: ubuntu-24.04-arm
- arch: aarch64
- - compiler: gcc
- cxx_compiler: g++
- packages: gcc g++
-
- steps:
- - name: Install dependencies
- run: |
- set -e
- export DEBIAN_FRONTEND=noninteractive
- sudo apt update -y
- sudo apt install -y autoconf curl fuse git kmod libbz2-dev libdjvulibre-dev libfontconfig-dev libfreetype6-dev libfribidi-dev libharfbuzz-dev liblcms-dev libopenexr-dev libopenjp2-7-dev libturbojpeg0-dev liblqr-dev libraqm-dev libtiff-dev libwebp-dev libx11-dev libxml2-dev liblzma-dev make software-properties-common wget ${{ matrix.packages }}
- sudo add-apt-repository ppa:git-core/ppa -y
- sudo apt install -y git
- sudo add-apt-repository ppa:strukturag/libheif -y
- sudo add-apt-repository ppa:strukturag/libde265 -y
- sudo apt install libheif-dev -y
-
- - name: Checkout
- uses: actions/checkout@v4
-
- # Avoid fatal: detected dubious ownership in repository at '/__w/ImageMagick/ImageMagick'
- # Possible workaround: https://github.com/actions/runner/issues/2033#issuecomment-1598547465
- - name: Flag current workspace as safe for git
- run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
-
- - name: Download AppImage
- run: |
- set -e
- sudo apt install -y file
- mkdir -p out/app-image
- cd out/app-image
- wget -c https://github.com/$(wget -q https://github.com/probonopd/go-appimage/releases/expanded_assets/continuous -O - | grep "appimagetool-.*-${{ matrix.arch }}.AppImage" | head -n 1 | cut -d '"' -f 2)
- chmod +x appimagetool-*.AppImage
-
- - name: Build ImageMagick
- env:
- CFLAGS:
- -Wno-deprecated-declarations -Wdeclaration-after-statement
- -Wno-error=unused-variable
- CC: ${{ matrix.compiler }}
- CXX: ${{ matrix.cxx_compiler }}
- run: |
- set -e
- ./configure --with-quantum-depth=16 --without-magick-plus-plus --without-perl --without-x --disable-docs --prefix=/usr
- make
- make install DESTDIR=$(readlink -f out/appdir)
-
- - name: Create ImageMagick AppImage
- run: |
- set -e
- mkdir -p out/appdir/usr/share/applications/
- cp app-image/imagemagick.desktop out/appdir/usr/share/applications/
- mkdir -p out/appdir/usr/share/icons/hicolor/256x256/apps/
- cp app-image/icon.png out/appdir/usr/share/icons/hicolor/256x256/apps/imagemagick.png
- unset QTDIR
- unset QT_PLUGIN_PATH
- unset LD_LIBRARY_PATH
- export VERSION=7
- cd out
- ./app-image/appimagetool-*.AppImage --appimage-extract-and-run -s deploy appdir/usr/share/applications/*.desktop
- chmod +x appdir/usr/lib/ld-linux-aarch64.so.1 || true
- ./app-image/appimagetool-*.AppImage --appimage-extract-and-run appdir
- mkdir artifacts
- cp ImageMagick*.AppImage artifacts/magick-${{ matrix.arch }}
-
- - name: Upload ImageMagick AppImage
- uses: actions/upload-artifact@v4
- with:
- name: magick-${{ matrix.arch }}
- path: out/artifacts
-
- - name: Create a draft GitHub release
- uses: ncipollo/release-action@v1
- with:
- artifacts: "out/artifacts/*"
- draft: true
- allowUpdates: true
- updateOnlyUnreleased: true
-
- download_and_keep_windows_binaries:
- name: Download magick binary (Windows)
- runs-on: ubuntu-24.04
- steps:
- - name: Download
- run: |
- mkdir -p out/artifacts
- curl -LO https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-43-portable-Q16-x64.zip
- unzip ImageMagick-7.1.1-43-portable-Q16-x64.zip
- cp ImageMagick-7.1.1-43-portable-Q16-x64/magick.exe out/artifacts/magick-x64.exe
- curl -LO https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-43-portable-Q16-arm64.zip
- unzip ImageMagick-7.1.1-43-portable-Q16-arm64.zip
- cp ImageMagick-7.1.1-43-portable-Q16-arm64/magick.exe out/artifacts/magick-arm64.exe
-
- - name: Upload ImageMagick exes
- uses: actions/upload-artifact@v4
- with:
- name: magick-${{ matrix.arch }}
- path: out/artifacts
-
- - name: Create a draft GitHub release
- uses: ncipollo/release-action@v1
- with:
- artifacts: "out/artifacts/*"
- draft: true
- allowUpdates: true
- updateOnlyUnreleased: true
diff --git a/desktop/scripts/vips/.gitignore b/desktop/scripts/vips/.gitignore
deleted file mode 100644
index dd38995058..0000000000
--- a/desktop/scripts/vips/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-1.heic
-1.jpeg
diff --git a/desktop/scripts/vips/Dockerfile b/desktop/scripts/vips/Dockerfile
deleted file mode 100644
index 11106e778a..0000000000
--- a/desktop/scripts/vips/Dockerfile
+++ /dev/null
@@ -1,18 +0,0 @@
-FROM ubuntu:24.04
-
-# https://github.com/libvips/libvips/blob/master/.github/workflows/ci.yml
-RUN apt-get update -y && apt-get install -y \
- meson pkg-config \
- libarchive-dev libcfitsio-dev libcgif-dev \
- libexif-dev libexpat1-dev libffi-dev \
- libfftw3-dev libheif-dev libheif-plugin-aomenc \
- libheif-plugin-x265 libhwy-dev libimagequant-dev \
- libjpeg-dev libjxl-dev liblcms2-dev \
- libmatio-dev libnifti-dev libopenexr-dev \
- libopenjp2-7-dev libopenslide-dev libpango1.0-dev \
- libpng-dev libpoppler-glib-dev librsvg2-dev \
- libtiff5-dev libwebp-dev
-
-RUN apt-get install -y git && git clone --depth 1 https://github.com/libvips/libvips
-
-WORKDIR /libvips
diff --git a/desktop/scripts/vips/Dockerfile.staticx b/desktop/scripts/vips/Dockerfile.staticx
deleted file mode 100644
index c2602e9e3a..0000000000
--- a/desktop/scripts/vips/Dockerfile.staticx
+++ /dev/null
@@ -1,74 +0,0 @@
-FROM debian:bullseye
-
-# Don't care about layer size.
-RUN apt-get update && apt-get install -y --no-install-recommends \
- gcc \
- gcc-10 \
- make \
- pkg-config
-
-# Don't care about layer size.
-RUN apt-get install -y --no-install-recommends \
- python3-minimal \
- python3-pip \
- python3-setuptools \
- patchelf
-
-RUN python3 -m pip \
- --disable-pip-version-check \
- --no-cache-dir \
- install \
- 'staticx==0.12.0'
-
-# Don't care about layer caching, because I'm only using docker for building.
-RUN apt-get install -y --no-install-recommends \
- ca-certificates \
- curl \
- g++ \
- g++-10 \
- libglib2.0-dev \
- libexpat1-dev \
- libjpeg-dev \
- libpng-dev \
- libimagequant-dev \
- libexif-dev \
- liborc-0.4-dev \
- && rm -rf /var/lib/apt/lists
-
-# TODO: Vendored source to remove test/ and doc/ with patches to remove test/ from configure.
-# This would also remove the need to install ca-certificates + curl.
-
-# TODO: libspng build with meson, miniz to replace libpng-dev.
-# https://github.com/randy408/libspng/blob/master/docs/build.md#meson
-# Then, publish the final image somewhere.
-
-WORKDIR /build
-RUN curl -sL https://github.com/libvips/libvips/releases/download/v8.10.1/vips-8.10.1.tar.gz | \
- tar -xz -f- --strip-components=1
-
-# XXX: -static doesn't work here. I'm using staticx to make the final vips binary static.
-# Could also try clang.
-# TODO: webp support
-RUN CFLAGS="-O2 -flto -pipe" CXXFLAGS="-O2 -flto -pipe" \
- ./configure \
- --disable-deprecated \
- --disable-shared \
- --disable-static \
- --disable-dependency-tracking \
- --disable-gtk-doc
-
-# This is the fastest easiest way I found to compile the
-# CLI as fast as possible. You can probably get more optimal,
-# but it'd be a lot harder wrestling autotools.
-RUN cd libvips \
- && make -j"$(nproc)"
-
-RUN cd tools \
- && make -j"$(nproc)" vips
-
-RUN cd tools \
- && staticx vips /bin/vips \
- && strip -s /bin/vips
-
-ENTRYPOINT ["/bin/vips"]
-CMD ["--help"]
diff --git a/desktop/scripts/vips/Dockerfile.vips-mini b/desktop/scripts/vips/Dockerfile.vips-mini
deleted file mode 100644
index daf346e5c8..0000000000
--- a/desktop/scripts/vips/Dockerfile.vips-mini
+++ /dev/null
@@ -1,38 +0,0 @@
-FROM --platform=linux/arm64/v8 alpine:3.18
-
-ARG VIPS_VERSION=8.14.5
-ARG ALPINE_VERSION=3.18
-
-# Environment variables
-ENV VIPS_HOME=/usr/local/vips-${VIPS_VERSION}
-ENV VIPS_BLOCK_UNTRUSTED=true \
- LD_LIBRARY_PATH=$VIPS_HOME/lib \
- PKG_CONFIG_PATH=$VIPS_HOME/lib/pkgconfig \
- PATH=$PATH:$VIPS_HOME/bin \
- WORKDIR=/usr/local/src
-
-WORKDIR $WORKDIR
-
-RUN apk add xz \
- && wget https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.xz \
- && tar -xf vips-${VIPS_VERSION}.tar.xz \
- && cd vips-${VIPS_VERSION} \
- && apk add \
- meson \
- build-base \
- vips-dev \
- fftw-dev \
- glib-dev \
- expat-dev expat \
- libjpeg-turbo-dev \
- libheif-dev \
- libspng-dev \
- curl
-
-RUN APK add curl-dev
-RUN meson configure -Dintrospection=false -Dmodules=disabled -Dexamples=false -Dheif=disabled -Djpeg=disabled -Dopenjpeg=disabled -Ddeprecated=false -Dcplusplus=false --default-library=static --prefer-static --buildtype release
-
-# RUN meson setup build-dir -Dintrospection=false -Dmodules=disabled -Dexamples=false --prefer-static --buildtype release \
-# && cd build-dir \
-# && meson compile \
-# && meson install
diff --git a/desktop/scripts/vips/README.md b/desktop/scripts/vips/README.md
deleted file mode 100644
index 2557893e95..0000000000
--- a/desktop/scripts/vips/README.md
+++ /dev/null
@@ -1,277 +0,0 @@
-Experimenting with libvips.
-
-```sh
-docker build -t vips-test .
-docker run -it --rm -v $(pwd):/w vips-test vips copy /w/1.heic /w/1.jpeg
-```
-
----
-
-## Notes 3
-
-Added a fork at https://github.com/ente-io/libvips-packaging.git
-
-```sh
-git clone https://github.com/ente-io/libvips-packaging
-cd libvips-packaging
-docker build -t vips-dev-linux-arm64 platforms/linux-arm64
-docker run -it --rm -e VERSION_VIPS=8.16.0 -e VERSION_LATEST_REQUIRED=false -v $(pwd):/packaging vips-dev-linux-arm64 /bin/bash
-# In the container
-$ /packaging/build/lin.sh
-```
-
-(ditto `linux-x64`)
-
-Meanwhile, to recreate the existing imagemagick thumbnail conversion pipeline
-
-```sh
-./vips --help-operation thumbnail
-./vips thumbnail sample.heic sample.heic.thumb.jpeg 720
-./vips thumbnail sample.heic sample.heic.thumb.jpeg[Q=50] 720
-```
-
-> The output image will fit within a square of size width x width
->
-> https://www.libvips.org/API/current/libvips-resample.html#vips-thumbnail
-
-> You can pass options to the implicit load and save operations enclosed in
-> square brackets after the filename:
->
-> vips affine k2.jpg x.jpg[Q=90,strip] "2 0 0 1"
->
-> https://www.libvips.org/API/current/using-cli.html
-
-For Windows,
-
-```sh
-git clone --depth 1 https://github.com/libvips/build-win64-mxe
-cd build-win64-mxe
-docker build -t libvips-build-win-mxe container
-docker run --rm -e VERSION_VIPS=8.16.0 -e FFI_COMPAT=false -e JPEG_IMPL=mozjpeg -e DISP=false -e HEVC=true -e DEBUG=false -e LLVM=true -e ZLIB_NG=true -v $(pwd)/build:/data libvips-build-win-mxe all x86_64-w64-mingw32.static
-docker run --rm -e VERSION_VIPS=8.16.0 -e FFI_COMPAT=false -e JPEG_IMPL=mozjpeg -e DISP=false -e HEVC=true -e DEBUG=false -e LLVM=true -e ZLIB_NG=true -v $(pwd)/build:/data libvips-build-win-mxe all aarch64-w64-mingw32.static
-```
-
-when testing, the following might be useful
-
-```sh
-docker run --rm -e VERSION_VIPS=8.16.0 -e FFI_COMPAT=false -e JPEG_IMPL=mozjpeg -e DISP=false -e HEVC=true -e DEBUG=false -e LLVM=true -e ZLIB_NG=true -v $(pwd)/build:/data --entrypoint /bin/bash libvips-build-win-mxe
-# Then in the container
-/data/build.sh all x86_64-w64-mingw32.static
-```
-
-Looks like we need a fork of build-win64-mxe because the default build takes TOO
-long for it to be feasible on a GitHub action. Even upstream seems to build
-elsewhere and upload the binaries.
-
-The slowness primarily comes because the mxe toolchain needs to be built from
-source, including llvm and rust. There used to be mxe packages, and perhaps they
-will again be in the future, but currrently the mxe pkg repo is not maintained
-and doesn't work with build-win64-mxe.
-
-While in our fork we can't trim of llvm itself, we can trim off a lot of
-dependencies that we don't need for our current purpose.
-
-The patch we need boils down to
-
-```patch
-diff --git a/build/vips-all.mk b/build/vips-all.mk
-index 33492f8..f79eedb 100644
---- a/build/vips-all.mk
-+++ b/build/vips-all.mk
-@@ -8,10 +8,10 @@ $(PKG)_PATCHES := $(realpath $(sort $(wildcard $(dir $(lastword $(MAKEFILE_LIST
- $(PKG)_GH_CONF := libvips/libvips/releases,v,,,,.tar.xz
- $(PKG)_SUBDIR := vips-$($(PKG)_VERSION)
- $(PKG)_FILE := vips-$($(PKG)_VERSION).tar.xz
--$(PKG)_DEPS := cc meson-wrapper libwebp librsvg glib pango libarchive \
-+$(PKG)_DEPS := cc meson-wrapper libwebp glib libarchive \
- libjpeg-turbo tiff lcms libexif libheif libpng \
-- libspng libimagequant highway imagemagick matio openexr \
-- cfitsio nifticlib poppler fftw openslide libjxl cgif
-+ libspng libimagequant highway \
-+ fftw cgif
-
- define $(PKG)_PRE_CONFIGURE
- # Copy some files to the packaging directory
-@@ -85,11 +85,16 @@ define $(PKG)_BUILD
- -Ddeprecated=false \
- -Dexamples=false \
- -Dintrospection=disabled \
-- -Dmodules=enabled \
-- -Dheif-module=$(if $(IS_HEVC),enabled,disabled) \
-- $(if $(findstring graphicsmagick,$($(PKG)_DEPS)), -Dmagick-package=GraphicsMagick) \
-+ -Dcplusplus=false \
-+ -Dmodules=disabled \
-+ -Dheif=enabled \
-+ -Dmagick=disabled \
- -Dpdfium=disabled \
- -Dquantizr=disabled \
-+ -Dpangocairo=disabled \
-+ -Dpoppler=disabled \
-+ -Drsvg=disabled \
-+ -Dopenslide=disabled \
- -Dc_args='$(CFLAGS) -DVIPS_DLLDIR_AS_LIBDIR' \
- '$(SOURCE_DIR)' \
- '$(BUILD_DIR)'
-```
-
-Custom fork's at https://github.com/ente-io/build-win64-mxe, invoke with
-
-```sh
-docker run -it --rm -v $(pwd)/build:/data --entrypoint /bin/bash libvips-build-win-mxe /data/custom.sh x86_64
-```
-
-(TODO Clean this entire document up and move to top level docs after we have a
-successful build)
-
-## Notes 2
-
-Try using libvips-packaging, see if it builds vips tools binaries too.
-
-```sh
-git clone https://github.com/kleisauke/libvips-packaging
-cd libvips-packaging
-docker build -t vips-dev-linux-arm64 platforms/linux-arm64
-docker run -it --rm -e VERSION_VIPS=8.16.0 -e VERSION_LATEST_REQUIRED=false -v $(pwd):/packaging vips-dev-linux-arm64 /bin/bash
-# In the container
-$ /packaging/build/lin.sh
-```
-
-This too is only producing the library, not the CLI tools.
-
-The following patch can be made to make it work (need to cleanup). It
-
-1. Builds `--default-library=static`
-2. Builds the tools and includes them in the package
-3. Adds libde265 for HEIC decoding
-
-```patch
-diff --git a/build/lin.sh b/build/lin-1-a.sh
-index 4400503..5d363c2 100755
---- a/build/lin.sh
-+++ b/build/lin-1-a.sh
-@@ -9,7 +9,7 @@ case ${PLATFORM} in
- TARGET=/target
- PACKAGE=/packaging
- ROOT=/root
-- VIPS_CPP_DEP=libvips-cpp.so.42
-+ VIPS_CPP_DEP=libvips.a
- ;;
- osx*)
- DARWIN=true
-@@ -271,6 +271,14 @@ AOM_AS_FLAGS="${FLAGS}" cmake -G"Unix Makefiles" \
- ..
- make install/strip
-
-+cd ${DEPS}
-+git clone --depth 1 https://github.com/strukturag/libde265.git
-+cd ${DEPS}/libde265
-+CFLAGS="${CFLAGS} -O3" CXXFLAGS="${CXXFLAGS} -O3" cmake -G"Unix Makefiles" \
-+ -DCMAKE_TOOLCHAIN_FILE=${ROOT}/Toolchain.cmake -DCMAKE_INSTALL_PREFIX=${TARGET} -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release \
-+ -DBUILD_SHARED_LIBS=FALSE
-+make install
-+
- mkdir ${DEPS}/heif
- $CURL https://github.com/strukturag/libheif/releases/download/v${VERSION_HEIF}/libheif-${VERSION_HEIF}.tar.gz | tar xzC ${DEPS}/heif --strip-components=1
- cd ${DEPS}/heif
-@@ -278,7 +286,7 @@ cd ${DEPS}/heif
- sed -i'.bak' "/^cmake_minimum_required/s/3.16.3/3.12/" CMakeLists.txt
- CFLAGS="${CFLAGS} -O3" CXXFLAGS="${CXXFLAGS} -O3" cmake -G"Unix Makefiles" \
- -DCMAKE_TOOLCHAIN_FILE=${ROOT}/Toolchain.cmake -DCMAKE_INSTALL_PREFIX=${TARGET} -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release \
-- -DBUILD_SHARED_LIBS=FALSE -DBUILD_TESTING=0 -DENABLE_PLUGIN_LOADING=0 -DWITH_EXAMPLES=0 -DWITH_LIBDE265=0 -DWITH_X265=0
-+ -DBUILD_SHARED_LIBS=FALSE -DBUILD_TESTING=0 -DENABLE_PLUGIN_LOADING=0 -DWITH_EXAMPLES=0 -DWITH_LIBDE265=1 -DWITH_X265=0
- make install/strip
- if [ "$PLATFORM" == "linux-arm" ]; then
- # Remove -lstdc++ from Libs.private, it won't work with -static-libstdc++
-@@ -468,8 +476,8 @@ if [ "$LINUX" = true ]; then
- printf "{local:g_param_spec_types;};" > vips.map
- fi
- # Disable building man pages, gettext po files, tools, and (fuzz-)tests
--sed -i'.bak' "/subdir('man')/{N;N;N;N;d;}" meson.build
--CFLAGS="${CFLAGS} -O3" CXXFLAGS="${CXXFLAGS} -O3" meson setup _build --default-library=shared --buildtype=release --strip --prefix=${TARGET} ${MESON} \
-+# sed -i'.bak' "/subdir('man')/{N;N;N;N;d;}" meson.build
-+CFLAGS="${CFLAGS} -O3" CXXFLAGS="${CXXFLAGS} -O3" meson setup _build --default-library=static --buildtype=release --strip --prefix=${TARGET} ${MESON} \
- -Ddeprecated=false -Dexamples=false -Dintrospection=disabled -Dmodules=disabled -Dcfitsio=disabled -Dfftw=disabled -Djpeg-xl=disabled \
- -Dmagick=disabled -Dmatio=disabled -Dnifti=disabled -Dopenexr=disabled -Dopenjpeg=disabled -Dopenslide=disabled \
- -Dpdfium=disabled -Dpoppler=disabled -Dquantizr=disabled \
-@@ -478,7 +486,7 @@ CFLAGS="${CFLAGS} -O3" CXXFLAGS="${CXXFLAGS} -O3" meson setup _build --default-l
- meson install -C _build --tag runtime,devel
-
- # Cleanup
--rm -rf ${TARGET}/lib/{pkgconfig,.libs,*.la,cmake}
-+# rm -rf ${TARGET}/lib/{pkgconfig,.libs,*.la,cmake}
-
- mkdir ${TARGET}/lib-filtered
- mv ${TARGET}/lib/glib-2.0 ${TARGET}/lib-filtered
-@@ -524,20 +532,20 @@ function copydeps {
- done;
- }
-
--cd ${TARGET}/lib
--if [ "$LINUX" = true ]; then
-- # Check that we really linked with -z nodelete
-- readelf -Wd libvips.so.42 | grep -qF NODELETE || (echo "libvips.so.42 was not linked with -z nodelete" && exit 1)
--fi
--if [ "$PLATFORM" == "linux-arm" ]; then
-- # Check that we really didn't link libstdc++ dynamically
-- readelf -Wd ${VIPS_CPP_DEP} | grep -qF libstdc && echo "$VIPS_CPP_DEP is dynamically linked against libstdc++" && exit 1
--fi
--if [ "${PLATFORM%-*}" == "linux-musl" ]; then
-- # Check that we really compiled with -D_GLIBCXX_USE_CXX11_ABI=1
-- # This won't work on RHEL/CentOS 7: https://stackoverflow.com/a/52611576
-- readelf -Ws ${VIPS_CPP_DEP} | c++filt | grep -qF "::__cxx11::" || (echo "$VIPS_CPP_DEP mistakenly uses the C++03 ABI" && exit 1)
--fi
-+# cd ${TARGET}/lib
-+# if [ "$LINUX" = true ]; then
-+# # Check that we really linked with -z nodelete
-+# readelf -Wd libvips.so.42 | grep -qF NODELETE || (echo "libvips.so.42 was not linked with -z nodelete" && exit 1)
-+# fi
-+# if [ "$PLATFORM" == "linux-arm" ]; then
-+# # Check that we really didn't link libstdc++ dynamically
-+# readelf -Wd ${VIPS_CPP_DEP} | grep -qF libstdc && echo "$VIPS_CPP_DEP is dynamically linked against libstdc++" && exit 1
-+# fi
-+# if [ "${PLATFORM%-*}" == "linux-musl" ]; then
-+# # Check that we really compiled with -D_GLIBCXX_USE_CXX11_ABI=1
-+# # This won't work on RHEL/CentOS 7: https://stackoverflow.com/a/52611576
-+# readelf -Ws ${VIPS_CPP_DEP} | c++filt | grep -qF "::__cxx11::" || (echo "$VIPS_CPP_DEP mistakenly uses the C++03 ABI" && exit 1)
-+# fi
- copydeps ${VIPS_CPP_DEP} ${TARGET}/lib-filtered
-
- # Create JSON file of version numbers
-@@ -583,6 +591,7 @@ mv lib-filtered lib
- tar chzf ${PACKAGE}/libvips-${VERSION_VIPS}-${PLATFORM}.tar.gz \
- include \
- lib \
-+ bin \
- versions.json \
- THIRD-PARTY-NOTICES.md
-```
-
-## Notes
-
-Everything disabled + static
-
-```sh
-meson setup _build --prefix=/target --default-library=static --buildtype=release -Ddeprecated=false -Dexamples=false -Dcplusplus=false -Dauto_features=disabled -Dmodules=disabled -Dintrospection=disabled -Dfftw=disabled -Dcgif=disabled -Dexif=disabled -Dfftw=disabled -Dfontconfig=disabled -Darchive=disabled -Dheif=disabled -Dheif-module=disabled -Dimagequant=disabled -Djpeg=disabled -Djpeg-xl=disabled -Djpeg-xl-module=disabled -Dlcms=disabled -Dmagick=disabled -Dmagick-module=disabled -Dmatio=disabled -Dnifti=disabled -Dopenexr=disabled -Dopenjpeg=disabled -Dopenslide=disabled -Dopenslide-module=disabled -Dhighway=disabled -Dorc=disabled -Dpangocairo=disabled -Dpdfium=disabled -Dpng=disabled -Dpoppler=disabled -Dpoppler-module=disabled -Dquantizr=disabled -Drsvg=disabled -Dspng=disabled -Dtiff=disabled -Dwebp=disabled -Dzlib=disabled -Dnsgif=false -Dppm=false -Danalyze=false -Dradiance=false
-```
-
-Patch meson.build
-
-```patch
-+glib_dep = dependency('glib-2.0', version: '>=2.52', static: true)
-+gio_dep = dependency('gio-2.0', static: true)
-+gobject_dep = dependency('gobject-2.0', static: true)
-+gmodule_dep = dependency('gmodule-no-export-2.0', required: get_option('modules'), static: true)
-+expat_dep = dependency('expat', static: true)
-+thread_dep = dependency('threads', static: true)
-```
-
----
-
-Creates an otherwise statically linked executable but still depends on system
-libs
-
-```sh
-meson setup _build --prefix=/target --default-library=static --buildtype=release -Ddeprecated=false -Dexamples=false -Dcplusplus=false -Dauto_features=disabled -Dmodules=disabled -Dcgif=disabled -Dexif=disabled -Dheif=disabled -Dheif-module=disabled -Dimagequant=disabled -Djpeg=disabled -Djpeg-xl=disabled -Djpeg-xl-module=disabled -Dlcms=disabled -Dhighway=disabled -Dspng=disabled -Dtiff=disabled -Dwebp=disabled -Dnsgif=false -Dppm=false -Danalyze=false -Dradiance=false -Dzlib=disabled
-
-cd build && meson compile && meson install
-```
diff --git a/desktop/src/main/services/image.ts b/desktop/src/main/services/image.ts
index 83bf437635..1c8574d287 100644
--- a/desktop/src/main/services/image.ts
+++ b/desktop/src/main/services/image.ts
@@ -14,7 +14,6 @@ export const convertToJPEG = async (imageData: Uint8Array) => {
const inputFilePath = await makeTempFilePath();
const outputFilePath = await makeTempFilePath("jpeg");
- // Construct the command first, it may throw NotAvailable on win32.
const command = convertToJPEGCommand(inputFilePath, outputFilePath);
try {
@@ -47,30 +46,11 @@ const convertToJPEGCommand = (
case "win32":
return [vipsPath(), "copy", inputFilePath, outputFilePath];
- // TODO: Cleanup im
- // return [
- // imageMagickPath(),
- // "convert",
- // inputFilePath,
- // "-quality",
- // "100%",
- // outputFilePath,
- // ];
-
default:
throw new Error("Not available on the current OS/arch");
}
};
-/**
- * Path to the magick executable bundled with our app on Linux and Windows.
- */
-const imageMagickPath = () =>
- path.join(
- isDev ? "build" : process.resourcesPath,
- process.platform == "win32" ? "magick.exe" : "magick",
- );
-
/**
* Path to the vips executable bundled with our app on Linux and Windows.
*/
@@ -158,24 +138,6 @@ const generateImageThumbnailCommand = (
`${maxDimension}`,
];
- case "aix" /* dummy case to hold TODO */:
- /* TODO: Cleanup im */
- return [
- imageMagickPath(),
- "convert",
- inputFilePath,
- "-define",
- `jpeg:size=${2 * maxDimension}x${2 * maxDimension}`,
- "-auto-orient",
- "-thumbnail",
- `${maxDimension}x${maxDimension}`,
- "-unsharp",
- "0x.5",
- "-quality",
- `${quality}`,
- outputFilePath,
- ];
-
default:
throw new Error("Not available on the current OS/arch");
}
diff --git a/desktop/src/main/utils/electron.ts b/desktop/src/main/utils/electron.ts
index 38e7e7e4c6..c11391dd65 100644
--- a/desktop/src/main/utils/electron.ts
+++ b/desktop/src/main/utils/electron.ts
@@ -56,8 +56,6 @@ export const execAsync = async (command: string | string[]) => {
const startTime = Date.now();
const result = await execAsync_(escapedCommand);
log.debug(() => `${escapedCommand} (${Date.now() - startTime} ms)`);
- // TODO(MR): Temp for debugging in nightlies; Remove before release.
- log.info(`${escapedCommand} (${Date.now() - startTime} ms)`);
return result;
};
diff --git a/web/apps/photos/src/services/upload/upload-service.ts b/web/apps/photos/src/services/upload/upload-service.ts
index beeb0bfc89..dc8208cbdb 100644
--- a/web/apps/photos/src/services/upload/upload-service.ts
+++ b/web/apps/photos/src/services/upload/upload-service.ts
@@ -1255,17 +1255,13 @@ const withThumbnail = async (
// only that works with non-File uploadItems), and the thumbnail
// generation failed.
//
- // The only know scenario is when we're trying to generate an image
- // thumbnail on Windows or on ARM64 Linux, or are trying to
- // generated the thumbnail for an HEIC file on Linux. This won't be
- // possible since the bundled imagemagick doesn't yet support these
- // OS/arch combinations.
+ // There are no expected scenarios when this should happen.
//
// The fallback in this case involves reading the entire stream into
// memory, and passing that data across the IPC boundary in a single
// go (i.e. not in a streaming manner). This is risky for videos of
// unbounded sizes, and since anyways we are not expected to come
- // here for videos, soo we only apply this fallback for images.
+ // here for videos, so we only apply this fallback for images.
if (fileTypeInfo.fileType == FileType.image) {
const data = await readEntireStream(fileStream.stream);
diff --git a/web/docs/heic.md b/web/docs/heic.md
index d13fa86265..b8da9e5e7f 100644
--- a/web/docs/heic.md
+++ b/web/docs/heic.md
@@ -76,14 +76,13 @@ and also as a web WASM build.
## libheif + libde265
-Every other HEIC converter, binary or library, I've seen eventually seems to use
-the uses the combination of libheif (for the HEIF container) + libde265 (for the
-HEVC decoding), with an option to swap libde265 with libx265 or kvazaar.
+Every other HEIC converter, binary or library (e.g. ImageMagick, GraphicsMagick,
+libvips, sharp and wasm-vips), I've seen eventually the uses the combination of
+libheif (for the HEIF container) + libde265 (for the HEVC decoding), with an
+option to swap libde265 with libx265 or kvazaar.
-Examples are ImageMagick, GraphicsMagick, libvips, sharp and wasm-vips. Good
-luck trying to get static binaries or readily usable WASM builds for any of
-these with HEIC support.
-
-We currently use
+Currently our web app uses
[heic-convert](https://github.com/catdad-experiments/heic-convert), which
-provides packaged WASM builds of libheif + libde265.
+provides packaged wasm builds of libheif + libde265, and the desktop app uses a
+[custom build](https://github.com/ente-io/libvips-packaging) of `vips` on Linux
+and Windows, and Apple's `sips` on macOS.
diff --git a/web/packages/base/types/ipc.ts b/web/packages/base/types/ipc.ts
index 55c180f2b8..da71b967f0 100644
--- a/web/packages/base/types/ipc.ts
+++ b/web/packages/base/types/ipc.ts
@@ -272,8 +272,7 @@ export interface Electron {
* Try to convert an arbitrary image into JPEG using native layer tools.
*
* The behaviour is OS dependent. On macOS we use the `sips` utility, while
- * on Linux and Windows we an ImageMagick executable bundled with our
- * desktop app.
+ * on Linux and Windows we use a `vips` bundled with our desktop app.
*
* @param imageData The raw image data (the contents of the image file).
*
@@ -285,8 +284,7 @@ export interface Electron {
* Generate a JPEG thumbnail for the given image.
*
* The behaviour is OS dependent. On macOS we use the `sips` utility, while
- * on Linux and Windows we an ImageMagick executable bundled with our
- * desktop app.
+ * on Linux and Windows we use a `vips` bundled with our desktop app.
*
* @param dataOrPathOrZipItem The file whose thumbnail we want to generate.
* It can be provided as raw image data (the contents of the image file), or