@@ -58,8 +58,10 @@ bool DecodeJpegXlOneShot(const uint8_t *jxl, size_t size,
5858 runner.get ())) {
5959 return false ;
6060 }
61-
62- JxlDecoderSetUnpremultiplyAlpha (dec.get (), JXL_TRUE);
61+
62+ if (JXL_DEC_SUCCESS != JxlDecoderSetUnpremultiplyAlpha (dec.get (), JXL_TRUE)) {
63+ return false ;
64+ }
6365
6466 JxlBasicInfo info;
6567 JxlPixelFormat format;
@@ -95,10 +97,6 @@ bool DecodeJpegXlOneShot(const uint8_t *jxl, size_t size,
9597 bitDepth = info.bits_per_sample ;
9698 *depth = info.bits_per_sample ;
9799 int baseComponents = info.num_color_channels ;
98- // Will not support mono
99- if (baseComponents < 3 ) {
100- baseComponents = 3 ;
101- }
102100 if (info.num_extra_channels > 0 ) {
103101 baseComponents = 4 ;
104102 }
@@ -129,19 +127,18 @@ bool DecodeJpegXlOneShot(const uint8_t *jxl, size_t size,
129127 // if (JXL_DEC_SUCCESS != JxlDecoderGetColorAsEncodedProfile(dec.get(), JXL_COLOR_PROFILE_TARGET_DATA, &colorEncoding)) {
130128 // return false;
131129 // }
132-
133- size_t icc_size;
134- if (JXL_DEC_SUCCESS !=
135- JxlDecoderGetICCProfileSize (dec.get (), JXL_COLOR_PROFILE_TARGET_DATA,
136- &icc_size)) {
137- return false ;
130+
131+ size_t iccSize;
132+ if (JXL_DEC_SUCCESS ==
133+ JxlDecoderGetICCProfileSize (dec.get (), JXL_COLOR_PROFILE_TARGET_DATA, &iccSize)) {
134+ iccProfile->resize (iccSize);
135+ if (JXL_DEC_SUCCESS != JxlDecoderGetColorAsICCProfile (dec.get (), JXL_COLOR_PROFILE_TARGET_DATA,
136+ iccProfile->data (), iccProfile->size ())) {
137+ return false ;
138+ }
139+ } else {
140+ iccProfile->resize (0 );
138141 }
139- iccProfile->resize (icc_size);
140- if (JXL_DEC_SUCCESS != JxlDecoderGetColorAsICCProfile (
141- dec.get (), JXL_COLOR_PROFILE_TARGET_DATA,
142- iccProfile->data (), iccProfile->size ())) {
143- return false ;
144- }
145142 } else if (status == JXL_DEC_NEED_IMAGE_OUT_BUFFER) {
146143 size_t buffer_size;
147144 if (JXL_DEC_SUCCESS !=
0 commit comments