Yalantis/uCrop · warning
save_pfm(): Instance is volumetric, only the first slice wil
Error message
save_pfm(): Instance is volumetric, only the first slice will be saved in file '%s'.
What it means
save_pfm() writes a 2D floating-point radiance map (Portable Float Map); CImg warns when _depth>1 because PFM has no volumetric extension and only the first z-slice (depth 0) is written. The remaining slices are silently dropped. Emitted via cimg::warn(), non-fatal.
Source
Thrown at ucrop/src/main/jni/CImg.h:62486
const CImg<T>& save_pfm(const char *const filename) const {
get_mirror('y')._save_pfm(0,filename);
return *this;
}
//! Save image as a PFM file \overloading.
const CImg<T>& save_pfm(std::FILE *const file) const {
get_mirror('y')._save_pfm(file,0);
return *this;
}
const CImg<T>& _save_pfm(std::FILE *const file, const char *const filename) const {
if (!file && !filename)
throw CImgArgumentException(_cimg_instance
"save_pfm(): Specified filename is (null).",
cimg_instance);
if (is_empty()) { cimg::fempty(file,filename); return *this; }
if (_depth>1)
cimg::warn(_cimg_instance
"save_pfm(): Instance is volumetric, only the first slice will be saved in file '%s'.",
cimg_instance,
filename?filename:"(FILE*)");
if (_spectrum>3)
cimg::warn(_cimg_instance
"save_pfm(): image instance is multispectral, only the three first channels will be saved "
"in file '%s'.",
cimg_instance,
filename?filename:"(FILE*)");
std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
const T
*ptr_r = data(0,0,0,0),
*ptr_g = (_spectrum>=2)?data(0,0,0,1):0,
*ptr_b = (_spectrum>=3)?data(0,0,0,2):0;
const unsigned int buf_size = std::min(1024*1024U,_width*_height*(_spectrum==1?1:3));
std::fprintf(nfile,"P%c\n%u %u\n1.0\n",View on GitHub (pinned to f788b534b4)
Solutions
- Save each slice separately: for (int z=0; z<img.depth(); ++z) img.get_slice(z).save_pfm(name_for_z)
- Use a volumetric-capable format (multi-page TIFF via save_tiff, or DICOM/NIfTI if available)
- If depth>1 is a bug, fix constructor argument order: CImg(w,h,1,c) for 2D images
Example fix
// before
volume.save_pfm("out.pfm"); // only slice 0 saved
// after
for (int z = 0; z < volume.depth(); ++z)
volume.get_slice(z).save_pfm(cimg::format("out_%03d.pfm", 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_pfm(cimg::format("out_%03d.pfm", z));
else
img.save_pfm("out.pfm"); Type guard
bool is_2d(const cimg_library::CImg<T>& img) { return img.depth() == 1; } Try / catch
try { img.save_pfm("out.pfm"); } catch (CImgException& e) { /* handle */ } Prevention
- Check depth() before 2D-only savers
- Save volumes to TIFF or native CImg format
- Verify constructor argument order (w,h,d,c) for 2D images
When it happens
Trigger: Calling save_pfm() on a volumetric CImg where _depth>1, e.g. after loading a multi-slice TIFF/NIfTI stack, building a 3D volume from slices, or an image accidentally constructed with depth>1.
Common situations: HDR pipelines handling image stacks; saving 3D medical imaging data to PFM; bugs where width/height/depth constructor arguments were passed in the wrong order producing unintended depth.
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
- save_exr(): Instance is volumetric, only the first slice wil
- save_other(): File '%s', saving a volumetric image with an e
- save_other(): File '%s', saving a volumetric image with an e
- save_other(): File '%s', saving a volumetric image with an e
- load_pfm(): Specified filename is (null).
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/355a0ff49d85da2b.
Report an issue: GitHub.