Yalantis/uCrop · warning

save_magick(): Instance is volumetric, only the first slice

Error message

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

What it means

Warning from CImg<T>::save_magick() (ImageMagick backend) when the image is volumetric (_depth>1). ImageMagick's Magick::Image API used here writes a single 2D image, so only the first slice is saved and the rest are dropped. The save continues successfully.

Source

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

#endif
    }

    //! Save image, using built-in ImageMagick++ library.
    /**
      \param filename Filename, as a C-string.
      \param bytes_per_pixel Force the number of bytes per pixel for the saving, when possible.
    **/
    const CImg<T>& save_magick(const char *const filename, const unsigned int bytes_per_pixel=0) const {
      if (!filename)
        throw CImgArgumentException(_cimg_instance
                                    "save_magick(): Specified filename is (null).",
                                    cimg_instance);
      if (is_empty()) { cimg::fempty(0,filename); return *this; }

#ifdef cimg_use_magick
      double stmin, stmax = (double)max_min(stmin);
      if (_depth>1)
        cimg::warn(_cimg_instance
                   "save_magick(): Instance is volumetric, only the first slice will be saved in file '%s'.",
                   cimg_instance,
                   filename);

      if (_spectrum>3)
        cimg::warn(_cimg_instance
                   "save_magick(): Instance is multispectral, only the three first channels will be "
                   "saved in file '%s'.",
                   cimg_instance,
                   filename);

      if (stmin<0 || (bytes_per_pixel==1 && stmax>=256) || stmax>=65536)
        cimg::warn(_cimg_instance
                   "save_magick(): Instance has pixel values in [%g,%g], probable type overflow in file '%s'.",
                   cimg_instance,
                   stmin,stmax,filename);

      Magick::Image image(Magick::Geometry(_width,_height),"black");

View on GitHub (pinned to f788b534b4)

Solutions

  1. Loop over slices: cimg_for_z(img,z) img.get_slice(z).save_magick(...);
  2. Use a multi-page capable format (e.g. save_tiff) or the .cimg native format
  3. Collapse the volume with get_projections_at() or take only the slice you need
  4. Ignore the warning if the first slice alone is intended

Example fix

// before
volume.save_magick("out.png");
// after
cimg_for_z(volume,z) volume.get_slice(z).save_magick(cimg::format("out_%d.png",z));
Defensive patterns

Strategy: validation

Validate before calling

if (img.depth() > 1) { /* save slices or choose another format */ }

Try / catch

// warning only; guard by depth check before calling save_magick

Prevention

When it happens

Trigger: Calling save_magick() on an image with depth > 1, e.g. a multi-frame stack built with CImg(w,h,d,s) or loaded from a volumetric format.

Common situations: Exporting 3D medical/scientific volumes or frame stacks to formats like PNG/JPEG/BMP through the Magick backend.

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/2728b4330754103d. Report an issue: GitHub.