Skip to content

Commit

Permalink
Merge pull request #10044 from cyruscook/pr-jxl-format
Browse files Browse the repository at this point in the history
JPEG XL output format support
  • Loading branch information
TurboGit committed Oct 24, 2022
2 parents a262c59 + 1e20064 commit 28547c0
Show file tree
Hide file tree
Showing 17 changed files with 787 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .ci/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ brew 'cmocka'
brew 'curl'
brew 'perl'
brew 'jpeg'
brew 'jpeg-xl'
brew 'webp'
4 changes: 4 additions & 0 deletions .ci/ci-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ case "$TARGET" in
-DUSE_NLS=OFF \
-DUSE_GRAPHICSMAGICK=OFF \
-DUSE_OPENJPEG=OFF \
-DUSE_JXL=OFF \
-DUSE_WEBP=OFF \
-DUSE_AVIF=OFF \
-DUSE_HEIF=OFF \
-DUSE_XCF=OFF \
-DBUILD_CMSTEST=OFF \
-DUSE_OPENEXR=OFF \
Expand All @@ -135,8 +137,10 @@ case "$TARGET" in
-DUSE_NLS=OFF \
-DUSE_GRAPHICSMAGICK=OFF \
-DUSE_OPENJPEG=OFF \
-DUSE_JXL=OFF \
-DUSE_WEBP=OFF \
-DUSE_AVIF=OFF \
-DUSE_HEIF=OFF \
-DUSE_XCF=OFF \
-DBUILD_CMSTEST=OFF \
-DUSE_OPENEXR=OFF \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ jobs:
libgphoto2:p
libheif:p
libjpeg-turbo:p
libjxl:p
libsecret:p
libsoup:p
libwebp:p
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
libgphoto2:p
libheif:p
libjpeg-turbo:p
libjxl:p
libsecret:p
libsoup:p
libwebp:p
Expand Down
1 change: 1 addition & 0 deletions DefineOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ option(BINARY_PACKAGE_BUILD "Sets march optimization to generic" OFF)
option(USE_XMLLINT "Run xmllint to test if darktableconfig.xml is valid" ON)
option(USE_PORTMIDI "Enable MIDI device support using PortMidi" ON)
option(USE_OPENJPEG "Enable JPEG 2000 support" ON)
option(USE_JXL "Enable JPEG XL export support" ON)
option(USE_WEBP "Enable WebP export support" ON)
option(USE_AVIF "Enable AVIF support" ON)
option(USE_HEIF "Enable HEIF/HEIC support" ON)
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,22 @@ Optional dependencies (minimum version):
* LLVM 3.9 *(for OpenCL checks at compilation time)*
* OpenCL 1.2 *(for GPU-accelerated computing)*
* Lua 5.4 *(for plugins and extension scripting)*
* libavif 0.8.2 *(for AVIF import/export)*
* libheif 1.9.0 *(for HEIF/HEIC/HIF import)*
* WebP 0.3.0 *(for WebP export)*
* libgphoto2 2.5 *(for camera tethering)*
* Imath 3.1.0 *(for 16-bit half float TIFF export and faster import)*
* libavif 0.8.2 *(for AVIF import & export)*
* libheif 1.9.0 *(for HEIF/HEIC/HIF import; also for AVIF import if no libavif)*
* libjxl 0.7.0 *(for JPEG XL export)*
* WebP 0.3.0 *(for WebP export)*

Optional dependencies (no version requirement):
* Lensfun *(for automatic lens correction)*
* OpenEXR *(for EXR import and export)*
* OpenJPEG *(for Jpeg2000 export)*
* colord, Xatom *(for fetching the system display color profile)*
* G'MIC *(for .gmz compressed LUT support)*
* PortMidi *(for MIDI input support)*
* SDL2 *(for gamepad input support)*
* CUPS *(for print mode support)*
* OpenEXR *(for EXR import & export)*
* OpenJPEG *(for JPEG 2000 import & export)*
* GraphicsMagick or ImageMagick *(for misc image format import)*

To install all the dependencies on Linux systems, you may use the source repositories of your distribution
Expand Down
38 changes: 38 additions & 0 deletions cmake/modules/FindJXL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Find libjxl
# Will define:
# - JXL_FOUND
# - JXL_INCLUDE_DIRS directory to include for libjxl headers
# - JXL_LIBRARIES libraries to link to

include(LibFindMacros)

# Use pkg-config to get hints about paths
# libfind_pkg_check_modules(JXL_PKGCONF libjxl) <- this isn't working?
pkg_check_modules(JXL_PKGCONF QUIET libjxl)

find_path(JXL_INCLUDE_DIR
NAMES jxl/encode.h
HINTS ${JXL_PKGCONF_INCLUDE_DIRS}
)

find_library(JXL_LIBRARY
NAMES jxl
HINTS ${JXL_PKGCONF_LIBRARY_DIRS}
)

find_library(JXL_THREADS_LIBRARY
NAMES jxl_threads
HINTS ${JXL_PKGCONF_LIBRARY_DIRS}
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(JXL DEFAULT_MSG JXL_LIBRARY JXL_INCLUDE_DIR)

if(JXL_PKGCONF_VERSION VERSION_LESS JXL_FIND_VERSION)
set(JXL_FOUND false)
endif()

if(JXL_FOUND)
set(JXL_LIBRARIES ${JXL_LIBRARY} ${JXL_THREADS_LIBRARY})
set(JXL_INCLUDE_DIRS ${JXL_INCLUDE_DIR})
endif(JXL_FOUND)
9 changes: 9 additions & 0 deletions cmake/windows-macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ if (WIN32 AND NOT BUILD_MSYS2_INSTALL)
)
list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${TMP_SYSTEM_RUNTIME_LIBS})
endif()

if(JXL_FOUND)
file(GLOB TMP_SYSTEM_RUNTIME_LIBS
#LIBJXL
${MINGW_PATH}/libjxl.dll
${MINGW_PATH}/libjxl_threads.dll
)
list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${TMP_SYSTEM_RUNTIME_LIBS})
endif()

if(WebP_FOUND)
file(GLOB TMP_SYSTEM_RUNTIME_LIBS
Expand Down
50 changes: 50 additions & 0 deletions data/darktableconfig.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -2613,6 +2613,56 @@
<shortdescription/>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/jxl/bpp</name>
<type>
<enum>
<option>8</option>
<option>10</option>
<option>12</option>
<option>16</option>
<option>32</option>
</enum>
</type>
<default>8</default>
<shortdescription>JPEG XL bit depth (bpp)</shortdescription>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/jxl/pixel_type</name>
<type>bool</type>
<default>false</default>
<shortdescription/>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/jxl/quality</name>
<type min="4" max="100">int</type>
<default>95</default>
<shortdescription/>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/jxl/original</name>
<type>bool</type>
<default>false</default>
<shortdescription/>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/jxl/effort</name>
<type min="1" max="9">int</type>
<default>7</default>
<shortdescription/>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/jxl/tier</name>
<type min="0" max="4">int</type>
<default>0</default>
<shortdescription/>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/webp/comp_type</name>
<type min="0" max="1">int</type>
Expand Down
4 changes: 3 additions & 1 deletion packaging/macosx/1_install_hb_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ hbDependencies="adwaita-icon-theme \
intltool \
iso-codes \
jpeg \
jpeg-xl \
json-glib \
lensfun \
libavif \
Expand All @@ -57,7 +58,8 @@ hbDependencies="adwaita-icon-theme \
po4a \
portmidi \
pugixml \
sdl2"
sdl2 \
webp"

# Install homebrew dependencies
for hbDependency in $hbDependencies; do
Expand Down
2 changes: 1 addition & 1 deletion packaging/macosx/BUILD-ARM64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ How to make disk image with darktable application bundle (64 bit ARM only):
$ portindex ~/ports
Add "file:///Users/<username>/ports" (change <username> to your actual login) to /opt/local/etc/macports/sources.conf before [default] line.
Install required dependencies:
$ sudo port install exiv2 libgphoto2 gtk-osx-application-gtk3 lensfun librsvg libsoup openexr json-glib GraphicsMagick openjpeg webp libsecret pugixml osm-gps-map adwaita-icon-theme tango-icon-theme intltool iso-codes libomp gmic-lib libheif portmidi libsdl2 libavif
$ sudo port install exiv2 libgphoto2 gtk-osx-application-gtk3 lensfun librsvg libsoup openexr json-glib GraphicsMagick openjpeg webp libsecret pugixml osm-gps-map adwaita-icon-theme tango-icon-theme intltool iso-codes libomp gmic-lib libheif portmidi libsdl2 libavif libjxl
Clone darktable git repository (in this example into ~/src):
$ mkdir ~/src
$ cd ~/src
Expand Down
2 changes: 1 addition & 1 deletion packaging/macosx/BUILD.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ How to make disk image with darktable application bundle (64 bit Intel only):
$ portindex ~/ports
Add "file:///Users/<username>/ports" (change <username> to your actual login) to /opt/local/etc/macports/sources.conf before [default] line.
Install required dependencies:
$ sudo port install exiv2 libgphoto2 gtk-osx-application-gtk3 lensfun librsvg libsoup openexr json-glib GraphicsMagick openjpeg webp libsecret pugixml osm-gps-map adwaita-icon-theme tango-icon-theme intltool iso-codes libomp gmic-lib libheif portmidi libsdl2 libavif
$ sudo port install exiv2 libgphoto2 gtk-osx-application-gtk3 lensfun librsvg libsoup openexr json-glib GraphicsMagick openjpeg webp libsecret pugixml osm-gps-map adwaita-icon-theme tango-icon-theme intltool iso-codes libomp gmic-lib libheif portmidi libsdl2 libavif libjxl
Clone darktable git repository (in this example into ~/src):
$ mkdir ~/src
$ cd ~/src
Expand Down
6 changes: 3 additions & 3 deletions packaging/windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To build darktable for the Windows operating system you have two basic options.
Native build using MSYS2
------------------------

How to make a darktable Windows installer (x64 only; Windows 8.1 or earlier will need to have UCRT installed):
How to make a darktable Windows installer (x64 only; Windows 8.1 or earlier will need to have [UCRT installed](https://support.microsoft.com/en-us/topic/update-for-universal-c-runtime-in-windows-c0514201-7fe6-95a3-b0a5-287930f3560c)):

* Install MSYS2 (instructions and prerequisites can be found on the official website: https://www.msys2.org)

Expand All @@ -25,7 +25,7 @@ How to make a darktable Windows installer (x64 only; Windows 8.1 or earlier will

* Install required libraries and dependencies for darktable:
```bash
pacman -S --needed mingw-w64-ucrt-x86_64-{exiv2,lcms2,lensfun,dbus-glib,openexr,sqlite3,libxslt,libsoup,libavif,libheif,libwebp,libsecret,lua,graphicsmagick,openjpeg2,gtk3,pugixml,libexif,osm-gps-map,libgphoto2,drmingw,gettext,python3,iso-codes,python3-jsonschema,python3-setuptools}
pacman -S --needed mingw-w64-ucrt-x86_64-{exiv2,lcms2,lensfun,dbus-glib,openexr,sqlite3,libxslt,libsoup,libavif,libheif,libjxl,libwebp,libsecret,lua,graphicsmagick,openjpeg2,gtk3,pugixml,libexif,osm-gps-map,libgphoto2,drmingw,gettext,python3,iso-codes,python3-jsonschema,python3-setuptools}
```

* Install optional libraries and dependencies:
Expand All @@ -39,7 +39,7 @@ How to make a darktable Windows installer (x64 only; Windows 8.1 or earlier will
pacman -S --needed mingw-w64-ucrt-x86_64-{portmidi,SDL2}
```

* Install optional libraries required for [testing](../../src/tests/unittests/README.md):
* Install optional libraries required for [testing](../../src/tests/unittests):
```bash
pacman -S --needed mingw-w64-ucrt-x86_64-cmocka
```
Expand Down
9 changes: 9 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,15 @@ if(USE_OPENEXR)
endif(OpenEXR_FOUND)
endif(USE_OPENEXR)

if(USE_JXL)
find_package(JXL 0.7.0)
if(JXL_FOUND)
include_directories(SYSTEM ${JXL_INCLUDE_DIRS})
list(APPEND LIBS ${JXL_LIBRARIES})
add_definitions(${JXL_DEFINITIONS})
endif(JXL_FOUND)
endif(USE_JXL)

if(USE_WEBP)
find_package(WebP 0.3.0)
if(WebP_FOUND)
Expand Down
10 changes: 10 additions & 0 deletions src/imageio/format/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ add_library(ppm MODULE "ppm.c")
add_library(pfm MODULE "pfm.c")
add_library(tiff MODULE "tiff.c")

if(JXL_FOUND)
list(APPEND MODULES "jxl_format")
add_library(jxl_format MODULE "jxl.c")
# At least on Windows, have to link to libjxl explicitly here as symbols
# from libdarktable get stripped (until read support is added). As a
# consequence, have to also change the module name to not be libjxl.
target_link_libraries(jxl_format PUBLIC ${JXL_LIBRARIES})
set_target_properties(jxl_format PROPERTIES OUTPUT_NAME jpegxl)
endif(JXL_FOUND)

if(WebP_FOUND)
list(APPEND MODULES "webp")
add_library(webp MODULE "webp.c")
Expand Down
Loading

0 comments on commit 28547c0

Please sign in to comment.