Yalantis/uCrop · warning

save_exr(): Instance is volumetric, only the first slice wil

Error message

save_exr(): Instance is volumetric, only the first slice will be saved in file '%s'.

What it means

save_exr() writes OpenEXR files which are 2D; CImg warns when _depth>1 because only the first slice (z=0) is written and the rest of the volume is silently dropped. Additionally, if CImg was not compiled with cimg_use_openexr the call falls back to save_other(). Emitted via cimg::warn(), non-fatal.

Source

Thrown at ucrop/src/main/jni/CImg.h:63124

      cimg::fwrite(header._data,256,nfile);
      cimg_forXYZ(*this,x,y,z) cimg_forC(*this,c) cimg::fwrite(&((*this)(x,y,z,c)),1,nfile);
      if (!file) cimg::fclose(nfile);
      return *this;
    }

    //! Save image as an OpenEXR file.
    /**
       \param filename Filename, as a C-string.
       \note The OpenEXR file format is <a href="http://en.wikipedia.org/wiki/OpenEXR">described here</a>.
    **/
    const CImg<T>& save_exr(const char *const filename) const {
      if (!filename)
        throw CImgArgumentException(_cimg_instance
                                    "save_exr(): Specified filename is (null).",
                                    cimg_instance);
      if (is_empty()) { cimg::fempty(0,filename); return *this; }
      if (_depth>1)
        cimg::warn(_cimg_instance
                   "save_exr(): Instance is volumetric, only the first slice will be saved in file '%s'.",
                   cimg_instance,
                   filename);

#ifndef cimg_use_openexr
      return save_other(filename);
#else
      Imf::Rgba *const ptrd0 = new Imf::Rgba[(size_t)_width*_height], *ptrd = ptrd0, rgba;
      switch (_spectrum) {
      case 1 : { // Grayscale image
        for (const T *ptr_r = data(), *const ptr_e = ptr_r + (ulongT)_width*_height; ptr_r<ptr_e;) {
          rgba.r = (half)(*(ptr_r));
          rgba.g = (half)(*(ptr_r));
          rgba.b = (half)(*(ptr_r++));
          rgba.a = (half)1;
          *(ptrd++) = rgba;
        }
      } break;

View on GitHub (pinned to f788b534b4)

Solutions

  1. Save slices individually: for z in range: img.get_slice(z).save_exr(name_for_z)
  2. Use a volumetric format (multi-page TIFF via save_tiff) or the native save_cimg() format
  3. Fix dimension order if depth>1 is unintended: CImg(w,h,1,c) for 2D images

Example fix

// before
volume.save_exr("out.exr");         // only slice 0
// after
for (int z = 0; z < volume.depth(); ++z)
  volume.get_slice(z).save_exr(cimg::format("out_%03d.exr", z));
Defensive patterns

Strategy: validation

Validate before calling

if (img.depth() > 1)
  for (int z = 0; z < img.depth(); ++z) img.get_slice(z).save_exr(cimg::format("out_%03d.exr", z));
else
  img.save_exr("out.exr");

Type guard

bool is_2d(const cimg_library::CImg<T>& img) { return img.depth() == 1; }

Try / catch

try { img.save_exr("out.exr"); } catch (CImgException& e) { /* handle */ }

Prevention

When it happens

Trigger: Calling save_exr() on a volumetric image (_depth>1), e.g. a 3D scan, image stack, or an image built with wrong dimension order.

Common situations: HDR pipelines handling volumes; saving light-field or z-stack data; accidentally constructing a 3D image when a 2D one was intended (constructor argument mix-up).

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08). Data as JSON: /api/errors/892fd9f8bb29348f. Report an issue: GitHub.