Skip to content

Instantly share code, notes, and snippets.

@schwehr
Last active January 9, 2025 04:59
Show Gist options
  • Save schwehr/b4b30e1896b14aa3dea7d44e34265965 to your computer and use it in GitHub Desktop.
Save schwehr/b4b30e1896b14aa3dea7d44e34265965 to your computer and use it in GitHub Desktop.
Enabling tif_jxl in libtiff
Same license as https://gitlab.com/libtiff/libtiff/-/blob/fa1d6d787fc67a1eeb3abccb790b5bee969d424b/LICENSE.md
Copied tif_jxl.c and tif_jxl.h from gdal/frmts/gtiff and then applied these changes
--- a/libtiff/tif_codec.c
+++ b/libtiff/tif_codec.c
@@ -90,6 +90,8 @@
{"ThunderScan", COMPRESSION_THUNDERSCAN, TIFFInitThunderScan},
{"NeXT", COMPRESSION_NEXT, TIFFInitNeXT},
{"JPEG", COMPRESSION_JPEG, TIFFInitJPEG},
+ {"JXL", COMPRESSION_JXL, TIFFInitJXL},
+ {"JXL_DNG_1_7", COMPRESSION_JXL_DNG_1_7, TIFFInitJXL},
{"Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG},
{"CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE},
{"CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW},
--- a/libtiff/tiffconf.h
+++ b/libtiff/tiffconf.h
@@ -84,6 +84,9 @@
/* Support JPEG compression (requires IJG JPEG library) */
#define JPEG_SUPPORT 1
+/* Support JPEG XL compression */
+#define JXL_SUPPORT 1
+
/* Support JBIG compression (requires JBIG-KIT library) */
/* #undef JBIG_SUPPORT */
--- a/libtiff/tiffiop.h 2024-12-30 21:05:14.000000000 +0000
+++ b/libtiff/tiffiop.h 2025-01-08 20:36:52.000000000 +0000
@@ -510,6 +510,9 @@
extern int TIFFInitJPEG(TIFF *, int);
extern int TIFFJPEGIsFullStripRequired(TIFF *);
#endif
+#ifdef JXL_SUPPORT
+ extern int TIFFInitJXL(TIFF *, int);
+#endif
#ifdef JBIG_SUPPORT
extern int TIFFInitJBIG(TIFF *, int);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment