Skip to contentSkip to conversation

package/zimg: add zimg package

PATCH Superseded Michael Cullen via buildroot 1 participant 3 messages Jan 6 – Jan 25

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/zimg: add zimg package

This commit adds an image transformation library called zimg.

There are a number of patches applied. One is from upstream and supports building on GCC-15, the others are autotools patches to allow installing various components useful for verifying the library is working on the target, which are not usually installed by the upstream project.

Note that while this version of zimg claims to support C++11 upwards, upstream is moving towards only supporting C++17 upwards in the master branch.

This has been tested on a Raspberry Pi 4 and a Raspberry Pi 5, and on x86_64 (run in a chroot).

---
 DEVELOPERS                                    |   3 +
 package/Config.in                             |   1 +
 package/zimg/0001-Fix-build-with-GCC-15.patch |  34 +++++
 package/zimg/0002-Install-test-app.patch      |  55 +++++++++
 package/zimg/0003-install-examples.patch      |  79 ++++++++++++
 .../0004-Add-option-to-install-tests.patch    | 116 ++++++++++++++++++
 package/zimg/Config.in                        |  27 ++++
 package/zimg/zimg.mk                          |  33 +++++
 8 files changed, 348 insertions(+)
 create mode 100644 package/zimg/0001-Fix-build-with-GCC-15.patch
 create mode 100644 package/zimg/0002-Install-test-app.patch
 create mode 100644 package/zimg/0003-install-examples.patch
 create mode 100644 package/zimg/0004-Add-option-to-install-tests.patch
 create mode 100644 package/zimg/Config.in
 create mode 100644 package/zimg/zimg.mk
DEVELOPERS +3 -0
index f982e3123a..940b621d8f 100644
@@ -2427,6 +2427,9 @@ N:	Meena Murthy <[email protected]>
 F:	board/engicam/px30core/
 F:	configs/engicam_px30_core_defconfig
 
+N:	Michael Cullen <[email protected]>
+F:	package/zimg/
+
 N:	Michael Durrant <[email protected]>
 F:	board/arcturus/
 F:	configs/arcturus_ucp1020_defconfig
package/Config.in +1 -0
index 352fd626e0..f5d1c79008 100644
@@ -1809,6 +1809,7 @@ menu "Graphics"
 	source "package/wpebackend-fdo/Config.in"
 	source "package/wpewebkit/Config.in"
 	source "package/zbar/Config.in"
+	source "package/zimg/Config.in"
 	source "package/zxing-cpp/Config.in"
 endmenu
 
package/zimg/0001-Fix-build-with-GCC-15.patch new file +34 -0
new file mode 100644
index 0000000000..d4f10d3a2b
@@ -0,0 +1,34 @@
+From 03e6c1e5a6f8420404cb035e975738db96628eb2 Mon Sep 17 00:00:00 2001
+From: Yaakov Selkowitz <[email protected]>
+Date: Tue, 18 Mar 2025 17:11:00 -0400
+Subject: [PATCH] Fix build with GCC 15
+
+```
+src/testcommon/mmap.cpp: In member function 'void MemoryMappedFile::impl::map_file(const char*, int, int, int)':
+src/testcommon/mmap.cpp:273:62: error: 'PTRDIFF_MAX' was not declared in this scope
+  273 |                 if ((file_size = posix::get_file_size(fd)) > PTRDIFF_MAX)
+      |                                                              ^~~~~~~~~~~
+src/testcommon/mmap.cpp:22:1: note: 'PTRDIFF_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
+```
+
+Upstream: https://github.com/sekrit-twc/zimg/commit/b013c7b006e6bee05b7964162f3a00402168e77f
+Signed-off-by: Michael Cullen <[email protected]>
+---
+ src/testcommon/mmap.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/testcommon/mmap.cpp b/src/testcommon/mmap.cpp
+index b6ba709..0310fa9 100644
+--- a/src/testcommon/mmap.cpp
++++ b/src/testcommon/mmap.cpp
+@@ -10,6 +10,7 @@
+   #include <Windows.h>
+ #else
+   #include <cerrno>
++  #include <cstdint>
+ 
+   #include <fcntl.h>
+   #include <unistd.h>
+-- 
+2.52.0
+
package/zimg/0002-Install-test-app.patch new file +55 -0

55 lines not on this page · raw message

package/zimg/0003-install-examples.patch new file +79 -0

79 lines not on this page · raw message

package/zimg/0004-Add-option-to-install-tests.patch new file +116 -0

116 lines not on this page · raw message

package/zimg/Config.in new file +27 -0
new file mode 100644
index 0000000000..3fbac545dc
@@ -0,0 +1,27 @@
+config BR2_PACKAGE_ZIMG
+	bool "zimg"
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # C++11
+	help
+	  Scaling, colorspace conversion, and dithering library
+
+	  https://github.com/sekrit-twc/zimg
+
+if BR2_PACKAGE_ZIMG
+
+config BR2_PACKAGE_ZIMG_TESTAPP
+	bool "zimg test app"
+
+config BR2_PACKAGE_ZIMG_EXAMPLES
+	bool "zimg examples"
+
+config BR2_PACKAGE_ZIMG_UNIT_TESTS
+	bool "zimg unit tests"
+
+config BR2_PACKAGE_ZIMG_DISABLE_SIMD
+	bool "Disable SIMD in zimg"
+
+endif
+
+comment "zimg needs a toolchain w/ C++11 support"
+	depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
package/zimg/zimg.mk new file +33 -0
new file mode 100644
index 0000000000..0dc314c765
@@ -0,0 +1,33 @@
+################################################################################
+#
+# zimg
+#
+################################################################################
+
+ZIMG_VERSION = release-3.0.6
+# This project uses submodules so the tarballs aren't really useful
+ZIMG_SITE_METHOD = git
+ZIMG_GIT_SUBMODULES = yes
+ZIMG_SITE = https://github.com/sekrit-twc/zimg.git
+ZIMG_LICENSE = WTFPL
+ZIMG_LICENSE_FILES = COPYING
+ZIMG_INSTALL_STAGING = YES
+ZIMG_AUTORECONF = YES
+
+ifeq ($(BR2_PACKAGE_ZIMG_TESTAPP),y)
+ZIMG_CONF_OPTS += --enable-testapp
+endif
+
+ifeq ($(BR2_PACKAGE_ZIMG_EXAMPLES),y)
+ZIMG_CONF_OPTS += --enable-example
+endif
+
+ifeq ($(BR2_PACKAGE_ZIMG_UNIT_TESTS),y)
+ZIMG_CONF_OPTS += --enable-unit-test --enable-install-tests
+endif
+
+ifeq ($(BR2_PACKAGE_ZIMG_DISABLE_SIMD),y)
+ZIMG_CONF_OPTS += --disable-simd
+endif
+
+$(eval $(autotools-package))
Signature · 6 lines
2.52.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hello Michael,

Quoted 7 lines · On Tue, 6 Jan 2026 19:57:26 +0100 Michael Cullen <[email protected]>…

This commit adds an image transformation library called zimg.

There are a number of patches applied. One is from upstream and supports building on GCC-15, the others are autotools patches to allow installing various components useful for verifying the library is working on the target, which are not usually installed by the upstream project.

Quoted 8 lines

Note that while this version of zimg claims to support C++11 upwards, upstream is moving towards only supporting C++17 upwards in the master branch.

This has been tested on a Raspberry Pi 4 and a Raspberry Pi 5, and on x86_64 (run in a chroot).

Thanks for this patch! It overall looks good, and I only have a few comments see below.

Quoted 7 lines
package/zimg/0002-Install-test-app.patch new file +1 -0
new file mode 100644
index 0000000000..cbafd0bd51
@@ -0,0 +1,55 @@
+From d4da533bec77c7f11aef08bed4888a82e1af8cba Mon Sep 17 00:00:00 2001

package/zimg/0002-Install-test-app.patch line 11

Quoted 10 lines
package/zimg/0002-Install-test-app.patch new file +10 -0
+From: Michael Cullen <[email protected]>
+Date: Tue, 6 Jan 2026 10:35:15 +0100
+Subject: [PATCH] Install test app
+
+To make sure zimg is working, it would be useful to be able to run the
+test app on the target. Currently, however, it is not installed.
+
+This patch renames it and installs it.
+
+Upstream: N/A - running test app on the target only applies to cross-compilation situations

For this one, and the other 2 patches that you marked as not upstreamable, could you take the same approach as your patch 0004-Add-option-to-install-tests.patch, which is to add a ./configure option to enable/disable installation of the test application, of the examples. And then it makes that upstreamable. You keep the default as disabled, so nothing changes, but you allow people like you/Buildroot who need those features to actually enable them. There's nothing "not upstreamable" in those changes IMO, and it would anyway not be nice to integrate a brand new package in Buildroot that has so many non-upstream patches.

Quoted 22 lines
package/zimg/Config.in new file +16 -0
new file mode 100644
index 0000000000..3fbac545dc
@@ -0,0 +1,27 @@
+config BR2_PACKAGE_ZIMG
+	bool "zimg"
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # C++11
+	help
+	  Scaling, colorspace conversion, and dithering library
+
+	  https://github.com/sekrit-twc/zimg
+
+if BR2_PACKAGE_ZIMG
+
+config BR2_PACKAGE_ZIMG_TESTAPP
+	bool "zimg test app"
+
+config BR2_PACKAGE_ZIMG_EXAMPLES
+	bool "zimg examples"

package/zimg/Config.in line 26

Quoted 10 lines
package/zimg/Config.in new file +10 -0
+
+config BR2_PACKAGE_ZIMG_UNIT_TESTS
+	bool "zimg unit tests"
+
+config BR2_PACKAGE_ZIMG_DISABLE_SIMD
+	bool "Disable SIMD in zimg"
+
+endif
+
+comment "zimg needs a toolchain w/ C++11 support"

This should be:

comment "zime needs a toolchain w/ C++, gcc >= 4.9"

Quoted 24 lines
package/zimg/Config.in new file +1 -0
+	depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
package/zimg/zimg.mk new file +17 -0
new file mode 100644
index 0000000000..0dc314c765
@@ -0,0 +1,33 @@
+################################################################################
+#
+# zimg
+#
+################################################################################
+
+ZIMG_VERSION = release-3.0.6
+# This project uses submodules so the tarballs aren't really useful
+ZIMG_SITE_METHOD = git
+ZIMG_GIT_SUBMODULES = yes
+ZIMG_SITE = https://github.com/sekrit-twc/zimg.git
+ZIMG_LICENSE = WTFPL
+ZIMG_LICENSE_FILES = COPYING
+ZIMG_INSTALL_STAGING = YES
+ZIMG_AUTORECONF = YES
+
+ifeq ($(BR2_PACKAGE_ZIMG_TESTAPP),y)

package/zimg/zimg.mk line 27

Quoted 10 lines
package/zimg/zimg.mk new file +10 -0
+ZIMG_CONF_OPTS += --enable-testapp
+endif
+
+ifeq ($(BR2_PACKAGE_ZIMG_EXAMPLES),y)
+ZIMG_CONF_OPTS += --enable-example
+endif
+
+ifeq ($(BR2_PACKAGE_ZIMG_UNIT_TESTS),y)
+ZIMG_CONF_OPTS += --enable-unit-test --enable-install-tests
+endif

Please add explicit disable in "else" clauses:

ifeq (...)
FOO_CONF_OPTS += --enable-bar
else
FOO_CONF_OPTS += --disable-bar
endif

package/zimg/zimg.mk line 29

Quoted 2 lines
package/zimg/zimg.mk new file +2 -0
+
+ifeq ($(BR2_PACKAGE_ZIMG_DISABLE_SIMD),y)

Meh, can we instead rely on existing architecture options, like MMX, SSE, AVX, NEON, etc. to decide whether to enable SIMD or not?

package/zimg/zimg.mk line 33

Quoted 4 lines
package/zimg/zimg.mk new file +4 -0
+ZIMG_CONF_OPTS += --disable-simd
+endif
+
+$(eval $(autotools-package))

Aside from those comments, looks good. Could you rework a bit, and submit a v2?

Thanks a lot!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH v2 1/1 package/zimg: add zimg package

In reply to Michael Cullen via buildroot

This commit adds an image transformation library called zimg.

There are a number of patches applied. One is from upstream and supports building on GCC-15, the others are autotools patches to allow installing various components useful for verifying the library is working on the target, which are not usually installed by the upstream project.

Note that while this version of zimg claims to support C++11 upwards, upstream is moving towards only supporting C++17 upwards in the master branch.

This has been tested on a Raspberry Pi 4 and a Raspberry Pi 5, and on x86_64 (run in a chroot).

---
Changes V1 -> V2:
- Submitted PR upstream with patches
- Changed help text to reference "gcc >= 4.9" rather than just "C++11"
- Added explicit "--disable-..." configure options
- Removed "disable SIMD" option as requested. This option was only there because the upstream configure script supports it so I decided to expose it. It probably isn't very useful in normal situations though

---
 DEVELOPERS                                    |   3 +
 package/Config.in                             |   1 +
 package/zimg/0001-Fix-build-with-GCC-15.patch |  34 +++++
 .../0002-Add-option-to-install-test-app.patch |  83 +++++++++++++
 .../0003-Add-option-to-install-examples.patch | 107 ++++++++++++++++
 .../0004-Add-option-to-install-tests.patch    | 116 ++++++++++++++++++
 package/zimg/Config.in                        |  28 +++++
 package/zimg/zimg.mk                          |  35 ++++++
 8 files changed, 407 insertions(+)
 create mode 100644 package/zimg/0001-Fix-build-with-GCC-15.patch
 create mode 100644 package/zimg/0002-Add-option-to-install-test-app.patch
 create mode 100644 package/zimg/0003-Add-option-to-install-examples.patch
 create mode 100644 package/zimg/0004-Add-option-to-install-tests.patch
 create mode 100644 package/zimg/Config.in
 create mode 100644 package/zimg/zimg.mk
DEVELOPERS +3 -0
index 08c98ec53b..975caf7035 100644
@@ -2412,6 +2412,9 @@ N:	Meena Murthy <[email protected]>
 F:	board/engicam/px30core/
 F:	configs/engicam_px30_core_defconfig
 
+N:	Michael Cullen <[email protected]>
+F:	package/zimg/
+
 N:	Michael Durrant <[email protected]>
 F:	board/arcturus/
 F:	configs/arcturus_ucp1020_defconfig
package/Config.in +1 -0
index 94ea56b297..6c603f7de0 100644
@@ -1804,6 +1804,7 @@ menu "Graphics"
 	source "package/wpebackend-fdo/Config.in"
 	source "package/wpewebkit/Config.in"
 	source "package/zbar/Config.in"
+	source "package/zimg/Config.in"
 	source "package/zxing-cpp/Config.in"
 endmenu
 
package/zimg/0001-Fix-build-with-GCC-15.patch new file +34 -0
new file mode 100644
index 0000000000..d4f10d3a2b
@@ -0,0 +1,34 @@
+From 03e6c1e5a6f8420404cb035e975738db96628eb2 Mon Sep 17 00:00:00 2001
+From: Yaakov Selkowitz <[email protected]>
+Date: Tue, 18 Mar 2025 17:11:00 -0400
+Subject: [PATCH] Fix build with GCC 15
+
+```
+src/testcommon/mmap.cpp: In member function 'void MemoryMappedFile::impl::map_file(const char*, int, int, int)':
+src/testcommon/mmap.cpp:273:62: error: 'PTRDIFF_MAX' was not declared in this scope
+  273 |                 if ((file_size = posix::get_file_size(fd)) > PTRDIFF_MAX)
+      |                                                              ^~~~~~~~~~~
+src/testcommon/mmap.cpp:22:1: note: 'PTRDIFF_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
+```
+
+Upstream: https://github.com/sekrit-twc/zimg/commit/b013c7b006e6bee05b7964162f3a00402168e77f
+Signed-off-by: Michael Cullen <[email protected]>
+---
+ src/testcommon/mmap.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/testcommon/mmap.cpp b/src/testcommon/mmap.cpp
+index b6ba709..0310fa9 100644
+--- a/src/testcommon/mmap.cpp
++++ b/src/testcommon/mmap.cpp
+@@ -10,6 +10,7 @@
+   #include <Windows.h>
+ #else
+   #include <cerrno>
++  #include <cstdint>
+ 
+   #include <fcntl.h>
+   #include <unistd.h>
+-- 
+2.52.0
+
package/zimg/0002-Add-option-to-install-test-app.patch new file +83 -0

83 lines not on this page · raw message

package/zimg/0003-Add-option-to-install-examples.patch new file +107 -0

107 lines not on this page · raw message

package/zimg/0004-Add-option-to-install-tests.patch new file +116 -0

116 lines not on this page · raw message

package/zimg/Config.in new file +28 -0
new file mode 100644
index 0000000000..2046f1426f
@@ -0,0 +1,28 @@
+config BR2_PACKAGE_ZIMG
+	bool "zimg"
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # C++11
+	help
+	  Scaling, colorspace conversion, and dithering library
+
+	  https://github.com/sekrit-twc/zimg
+
+if BR2_PACKAGE_ZIMG
+
+config BR2_PACKAGE_ZIMG_TESTAPP
+	bool "zimg test app"
+
+config BR2_PACKAGE_ZIMG_EXAMPLES
+	bool "zimg examples"
+
+config BR2_PACKAGE_ZIMG_UNIT_TESTS
+	bool "zimg unit tests"
+	help
+	  Build the Zimg unit tests. Note: building these enables some
+	  compilation options to improve repeatability, but these may
+	  reduce performance
+
+endif
+
+comment "zimg needs a toolchain w/ C++, gcc >= 4.9"
+	depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
package/zimg/zimg.mk new file +35 -0
new file mode 100644
index 0000000000..3029b3e7b9
@@ -0,0 +1,35 @@
+################################################################################
+#
+# zimg
+#
+################################################################################
+
+ZIMG_VERSION = release-3.0.6
+# This project uses submodules so the tarballs aren't really useful
+ZIMG_SITE_METHOD = git
+ZIMG_GIT_SUBMODULES = yes
+ZIMG_SITE = https://github.com/sekrit-twc/zimg.git
+ZIMG_LICENSE = WTFPL
+ZIMG_LICENSE_FILES = COPYING
+ZIMG_INSTALL_STAGING = YES
+ZIMG_AUTORECONF = YES
+
+ifeq ($(BR2_PACKAGE_ZIMG_TESTAPP),y)
+ZIMG_CONF_OPTS += --enable-testapp --enable-install-testapp
+else
+ZIMG_CONF_OPTS += --disable-testapp --disable-install-testapp
+endif
+
+ifeq ($(BR2_PACKAGE_ZIMG_EXAMPLES),y)
+ZIMG_CONF_OPTS += --enable-example --enable-install-examples
+else
+ZIMG_CONF_OPTS += --disable-example --disable-install-examples
+endif
+
+ifeq ($(BR2_PACKAGE_ZIMG_UNIT_TESTS),y)
+ZIMG_CONF_OPTS += --enable-unit-test --enable-install-tests
+else
+ZIMG_CONF_OPTS += --disable-unit-test --disable-install-tests
+endif
+
+$(eval $(autotools-package))
Signature · 6 lines
2.52.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot