{"record":{"id":"2728b4330754103d","repo":"Yalantis/uCrop","slug":"save-magick-instance-is-volumetric-only-the-fi","errorCode":null,"errorMessage":"save_magick(): Instance is volumetric, only the first slice will be saved in file '%s'.","messagePattern":"save_magick\\(\\): 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":61984,"sourceCode":"#endif\n    }\n\n    //! Save image, using built-in ImageMagick++ library.\n    /**\n      \\param filename Filename, as a C-string.\n      \\param bytes_per_pixel Force the number of bytes per pixel for the saving, when possible.\n    **/\n    const CImg<T>& save_magick(const char *const filename, const unsigned int bytes_per_pixel=0) const {\n      if (!filename)\n        throw CImgArgumentException(_cimg_instance\n                                    \"save_magick(): Specified filename is (null).\",\n                                    cimg_instance);\n      if (is_empty()) { cimg::fempty(0,filename); return *this; }\n\n#ifdef cimg_use_magick\n      double stmin, stmax = (double)max_min(stmin);\n      if (_depth>1)\n        cimg::warn(_cimg_instance\n                   \"save_magick(): Instance is volumetric, only the first slice will be saved in file '%s'.\",\n                   cimg_instance,\n                   filename);\n\n      if (_spectrum>3)\n        cimg::warn(_cimg_instance\n                   \"save_magick(): Instance is multispectral, only the three first channels will be \"\n                   \"saved in file '%s'.\",\n                   cimg_instance,\n                   filename);\n\n      if (stmin<0 || (bytes_per_pixel==1 && stmax>=256) || stmax>=65536)\n        cimg::warn(_cimg_instance\n                   \"save_magick(): Instance has pixel values in [%g,%g], probable type overflow in file '%s'.\",\n                   cimg_instance,\n                   stmin,stmax,filename);\n\n      Magick::Image image(Magick::Geometry(_width,_height),\"black\");","sourceCodeStart":61966,"sourceCodeEnd":62002,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L61966-L62002","documentation":"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.","triggerScenarios":"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.","commonSituations":"Exporting 3D medical/scientific volumes or frame stacks to formats like PNG/JPEG/BMP through the Magick backend.","solutions":["Loop over slices: cimg_for_z(img,z) img.get_slice(z).save_magick(...);","Use a multi-page capable format (e.g. save_tiff) or the .cimg native format","Collapse the volume with get_projections_at() or take only the slice you need","Ignore the warning if the first slice alone is intended"],"exampleFix":"// before\nvolume.save_magick(\"out.png\");\n// after\ncimg_for_z(volume,z) volume.get_slice(z).save_magick(cimg::format(\"out_%d.png\",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_magick","preventionTips":["Check img.depth() before saving via Magick backend","Use multi-page formats for volumes"],"tags":["image-encoding","volumetric-data","imagemagick"],"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"}