@@ -327,15 +327,29 @@ impl Interpreter {
327327 // ─── JPEG: use turbojpeg with native scaled DCT decoding ─────────
328328 let ( img_w, img_h, rgba) = if is_jpeg {
329329 let raw = & stream. content ;
330+ eprintln ! ( "[IMG] JPEG {}x{}, {} bytes, budget={}" , width, height, raw. len( ) , max_decode_pixels) ;
330331 match Self :: decode_jpeg_scaled ( raw, max_decode_pixels) {
331- Some ( result) => result,
332- None => return ,
332+ Some ( result) => {
333+ eprintln ! ( "[IMG] -> decoded to {}x{}" , result. 0 , result. 1 ) ;
334+ result
335+ }
336+ None => {
337+ eprintln ! ( "[IMG] -> DECODE FAILED!" ) ;
338+ return ;
339+ }
333340 }
334341 } else {
335342 // ─── Non-JPEG: raw pixel decode + optional box downsample ────
343+ eprintln ! ( "[IMG] RAW {}x{}, budget={}" , width, height, max_decode_pixels) ;
336344 match Self :: decode_raw_image ( dict, stream, doc, width, height, max_decode_pixels) {
337- Some ( result) => result,
338- None => return ,
345+ Some ( result) => {
346+ eprintln ! ( "[IMG] -> decoded to {}x{}" , result. 0 , result. 1 ) ;
347+ result
348+ }
349+ None => {
350+ eprintln ! ( "[IMG] -> DECODE FAILED!" ) ;
351+ return ;
352+ }
339353 }
340354 } ;
341355
@@ -382,8 +396,14 @@ impl Interpreter {
382396
383397 /// Try turbojpeg native scaled DCT decode. Returns None on any failure.
384398 fn try_turbojpeg ( jpeg_data : & [ u8 ] , max_pixels : u32 ) -> Option < ( u32 , u32 , Vec < u8 > ) > {
385- let mut dc = turbojpeg:: Decompressor :: new ( ) . ok ( ) ?;
386- let header = dc. read_header ( jpeg_data) . ok ( ) ?;
399+ let mut dc = match turbojpeg:: Decompressor :: new ( ) {
400+ Ok ( d) => d,
401+ Err ( e) => { eprintln ! ( "[IMG] turbojpeg: Decompressor::new failed: {}" , e) ; return None ; }
402+ } ;
403+ let header = match dc. read_header ( jpeg_data) {
404+ Ok ( h) => h,
405+ Err ( e) => { eprintln ! ( "[IMG] turbojpeg: read_header failed: {}" , e) ; return None ; }
406+ } ;
387407 let full_w = header. width ;
388408 let full_h = header. height ;
389409
@@ -425,7 +445,11 @@ impl Interpreter {
425445 format : turbojpeg:: PixelFormat :: RGBA ,
426446 } ;
427447
428- dc. decompress ( jpeg_data, image. as_deref_mut ( ) ) . ok ( ) ?;
448+ eprintln ! ( "[IMG] turbojpeg: decompress {}x{} -> {}x{}" , full_w, full_h, out_w, out_h) ;
449+ match dc. decompress ( jpeg_data, image. as_deref_mut ( ) ) {
450+ Ok ( _) => { } ,
451+ Err ( e) => { eprintln ! ( "[IMG] turbojpeg: decompress FAILED: {}" , e) ; return None ; }
452+ }
429453 Some ( ( out_w as u32 , out_h as u32 , image. pixels ) )
430454 }
431455
0 commit comments