{"record":{"id":"5a065fe08d564da4","repo":"Yalantis/uCrop","slug":"save-magick-instance-is-multispectral-only-the","errorCode":null,"errorMessage":"save_magick(): Instance is multispectral, only the three first channels will be saved in file '%s'.","messagePattern":"save_magick\\(\\): Instance is multispectral, only the three first channels will be saved in file '(.+?)'\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":61990,"sourceCode":"      \\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\");\n      image.type(Magick::TrueColorType);\n      image.depth(bytes_per_pixel?(8*bytes_per_pixel):(stmax>=256?16:8));\n      const T\n        *ptr_r = data(0,0,0,0),\n        *ptr_g = _spectrum>1?data(0,0,0,1):0,\n        *ptr_b = _spectrum>2?data(0,0,0,2):0;","sourceCodeStart":61972,"sourceCodeEnd":62008,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L61972-L62008","documentation":"Warning from CImg<T>::save_magick() when the image has more than 3 channels (_spectrum>3). The Magick::Image created here is TrueColor RGB (3 channels), so channels beyond the first three (e.g. alpha plus extra bands, multispectral data) are dropped. The save still completes.","triggerScenarios":"Calling save_magick() on an image whose _spectrum exceeds 3, such as 4-channel RGBA-plus data or N-band hyperspectral images.","commonSituations":"Saving remote-sensing/hyperspectral imagery, or RGBA images where a 4th channel (alpha) is silently dropped in TrueColorType mode.","solutions":["Reduce to RGB explicitly before saving (e.g. get_channels(0,2)) or extract the bands you need","Save extra channels separately as individual images","Use a format/backend that supports N channels (save_tiff, or .cimg)","Ignore if dropping alpha/extra bands is acceptable"],"exampleFix":"// before\nrgba_hyperspectral.save_magick(\"out.png\"); // channels 3+ dropped\n// after\nrgba_hyperspectral.get_channels(0,2).save_magick(\"out.png\");","handlingStrategy":"validation","validationCode":"if (img.spectrum() > 3) img = img.get_channels(0,2); // then save_magick","typeGuard":null,"tryCatchPattern":"// warning only; guard by spectrum check before calling save_magick","preventionTips":["Check img.spectrum() before saving to RGB-only backends","Keep extra channels in TIFF/.cimg"],"tags":["image-encoding","channels","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"}