{"record":{"id":"2a8934b0a1ef3c93","repo":"Yalantis/uCrop","slug":"save-jxl-instance-is-volumetric-only-the-first","errorCode":null,"errorMessage":"save_jxl(): Instance is volumetric, only the first slice will be saved in file '%s'.","messagePattern":"save_jxl\\(\\): Instance is volumetric, only the first slice will be saved in file '(.+?)'\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":61784,"sourceCode":"        throw CImgArgumentException(_cimg_instance\n                                    \"save_jxl(): Specified filename is (null).\",\n                                    cimg_instance);\n      if (_spectrum > 4)\n        throw CImgArgumentException(_cimg_instance\n                                    \"save_jxl(): JPEG XL only supports at most 4 channels.\",\n                                    cimg_instance);\n      double stmin, stmax = (double)max_min(stmin);\n      if (stmin<0 || (bytes_per_pixel==1 && stmax>=256) || stmax>=65536)\n        cimg::warn(_cimg_instance\n                   \"save_jxl(): Instance has pixel values in [%g,%g], probable type overflow in file '%s'.\",\n                   cimg_instance,\n                   stmin,stmax,filename);\n      if (bytes_per_pixel>2 || sizeof(T)<bytes_per_pixel)\n        throw CImgArgumentException(_cimg_instance\n                                    \"save_jxl(): bytes_per_pixel must be in [0, 2] and less than or equal to sizeof(T)\",\n                                    cimg_instance);\n      if (_depth>1)\n        cimg::warn(_cimg_instance\n                   \"save_jxl(): Instance is volumetric, only the first slice will be saved in file '%s'.\",\n                   cimg_instance,\n                   filename);\n#ifndef cimg_use_jxl\n      cimg::unused(distance);\n      return save_other(filename);\n#else\n      std::FILE *file = cimg::fopen(filename, \"wb\");\n      cimg_uint32 nChannels = _spectrum;\n      bool hasAlpha = _spectrum==2 || _spectrum==4;\n      if (hasAlpha) --nChannels;\n      unsigned int bytesPerPixel = bytes_per_pixel;\n      if (bytesPerPixel==0)\n          bytesPerPixel = stmax<256?1:2;\n      CImg<ucharT> rgbBuffer(_width*_height*nChannels*bytesPerPixel);\n      const T *ptr_r = 0, *ptr_g = 0, *ptr_b = 0, *ptr_a = 0;\n      switch (_spectrum) {\n      case 1:","sourceCodeStart":61766,"sourceCodeEnd":61802,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L61766-L61802","documentation":"Warning emitted by CImg<T>::save_jxl() when the image has depth > 1 (a volumetric image, i.e. a 3D stack). JPEG XL stores single 2D images, so only the first slice (z=0) is written to the file and all other slices are silently dropped. The save itself succeeds.","triggerScenarios":"Calling save_jxl() on a CImg whose _depth>1, e.g. after get_slice() misuse, loading a multi-page/multi-frame volume, or constructing an image with depth dimension greater than 1.","commonSituations":"Saving medical imaging volumes (MRI/CT stacks), video frames stored as depth, or z-stacks loaded from TIFF/NIfTI directly to JPEG XL.","solutions":["Save each slice separately: cimg_for_z(img,z) img.get_slice(z).save_jxl(...);","Use a volume-capable format (TIFF, NIfTI, .cimg) instead","Flatten or project the volume if a single 2D result is intended","Ignore if only the first slice is wanted"],"exampleFix":"// before\nvolume.save_jxl(\"out.jxl\"); // only slice 0 saved\n// after\ncimg_for_z(volume,z) volume.get_slice(z).save_jxl(cimg::format(\"out_%d.jxl\",z));","handlingStrategy":"validation","validationCode":"if (img.depth() > 1) { /* save slices or choose another format */ }","typeGuard":null,"tryCatchPattern":"// warning only; guard by depth check before calling save_jxl","preventionTips":["Check img.depth() before saving to 2D-only formats","Use TIFF/.cimg for volumetric data"],"tags":["image-encoding","volumetric-data","jxl"],"backgroundTag":"unsupported-operation","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}