From d45f534d6843282992251fee612e23d4d2228fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= <1671644+arrufat@users.noreply.github.com> Date: Wed, 6 Mar 2024 10:15:10 +0900 Subject: [PATCH] Add missing magic number for JPEG XL (#2924) * Add missing magic number for JPEG XL * do not force JXL container --- dlib/image_loader/load_image.h | 5 +++-- dlib/image_saver/save_jxl.cpp | 5 ----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/dlib/image_loader/load_image.h b/dlib/image_loader/load_image.h index d6130b01f..4f414b600 100644 --- a/dlib/image_loader/load_image.h +++ b/dlib/image_loader/load_image.h @@ -57,11 +57,12 @@ namespace dlib return DNG; else if (buffer[0]=='G' && buffer[1]=='I' && buffer[2] == 'F') return GIF; + else if ((buffer[0] == '\xff' && buffer[1] == '\x0a') || + memcmp(buffer, jxlHeader, 12) == 0) // we can't use strlen because the header starts with \x00. + return JXL; else if (buffer[0]=='R' && buffer[1]=='I' && buffer[2] == 'F' && buffer[3] == 'F' && buffer[8]=='W' && buffer[9]=='E' && buffer[10] == 'B' && buffer[11] == 'P') return WEBP; - else if (memcmp(buffer, jxlHeader, 12) == 0) // we can't use strlen because the header starts with \x00. - return JXL; return UNKNOWN; } diff --git a/dlib/image_saver/save_jxl.cpp b/dlib/image_saver/save_jxl.cpp index 567b28693..9f40fcd41 100644 --- a/dlib/image_saver/save_jxl.cpp +++ b/dlib/image_saver/save_jxl.cpp @@ -34,11 +34,6 @@ namespace dlib { } auto enc = JxlEncoderMake(nullptr); - if (JXL_ENC_SUCCESS != JxlEncoderUseContainer(enc.get(), JXL_TRUE)) - { - throw image_save_error("jxl_saver: JxlEncoderUseContainer failed"); - } - auto runner = JxlResizableParallelRunnerMake(nullptr); JxlResizableParallelRunnerSetThreads(runner.get(), JxlResizableParallelRunnerSuggestThreads(width, height));