Skip to content

Commit

Permalink
JPEG XL output format support
Browse files Browse the repository at this point in the history
Add support for writing JPEG XL formatted images.
More information about the JPEG XL format can be found here: https://jpeg.org/jpegxl/index.html .
  • Loading branch information
cyruscook committed Sep 20, 2021
1 parent 0ed01f3 commit 40dfc93
Show file tree
Hide file tree
Showing 8 changed files with 591 additions and 0 deletions.
1 change: 1 addition & 0 deletions DefineOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ option(BUILD_USERMANUAL "Build all the versions of the usermanual." OFF)
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_OPENJPEG "Enable JPEG 2000 support" ON)
option(USE_JXL "Enabled JPEG XL export support" ON)
option(USE_WEBP "Enable WebP export support" ON)
option(USE_AVIF "Enable AVIF support" ON)
option(USE_XCF "Enable XCF support" ON)
Expand Down
33 changes: 33 additions & 0 deletions cmake/modules/FindJXL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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)

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_FOUND)
set(JXL_LIBRARIES ${JXL_LIBRARY} ${JXL_THREADS_LIBRARY})
set(JXL_INCLUDE_DIRS ${JXL_INCLUDE_DIR})
ENDIF(JXL_FOUND)
2 changes: 2 additions & 0 deletions cmake/modules/FindOpenJPEG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ find_library(OpenJPEG_LIBRARY
set(OpenJPEG_PROCESS_INCLUDES OpenJPEG_INCLUDE_DIR)
set(OpenJPEG_PROCESS_LIBS OpenJPEG_LIBRARY)
libfind_process(OpenJPEG)


8 changes: 8 additions & 0 deletions cmake/windows-macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ 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
)
list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${TMP_SYSTEM_RUNTIME_LIBS})
endif()

if(WebP_FOUND)
file(GLOB TMP_SYSTEM_RUNTIME_LIBS
Expand Down
35 changes: 35 additions & 0 deletions data/darktableconfig.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,41 @@
<shortdescription/>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/jxl/lossless</name>
<type>bool</type>
<default>false</default>
<shortdescription/>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/jxl/quality</name>
<type min="0.0" max="15.0">float</type>
<default>14.0</default>
<shortdescription/>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/jxl/encoding_effort</name>
<type min="1" max="9">int</type>
<default>3</default>
<shortdescription/>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/jxl/decoding_effort</name>
<type min="0" max="4">int</type>
<default>0</default>
<shortdescription/>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/jxl/container</name>
<type>string</type>
<default>bmff</default>
<shortdescription/>
<longdescription/>
</dtconfig>
<dtconfig>
<name>plugins/imageio/format/webp/comp_type</name>
<type min="0" max="1">int</type>
Expand Down
9 changes: 9 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,15 @@ if(USE_OPENEXR)
endif(OpenEXR_FOUND)
endif(USE_OPENEXR)

if(USE_JXL)
find_package(JXL)
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
5 changes: 5 additions & 0 deletions src/imageio/format/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ 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")
add_library(jxl MODULE "jxl.c")
endif(JXL_FOUND)

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

0 comments on commit 40dfc93

Please sign in to comment.