Yalantis/uCrop · error · CImgIOException
save_other(): Failed to save file '%s'. Format is not native
Error message
save_other(): Failed to save file '%s'. Format is not natively supported, and no external commands succeeded.
What it means
save_other() tries every registered external tool in turn (ImageMagick, GraphicsMagick, medcon) and restores the original exception mode afterwards. If none of the tools succeeded in creating the file, CImg throws CImgIOException stating the format is not natively supported and no external command succeeded. Essentially: this format cannot be written on this system at all.
Source
Thrown at ucrop/src/main/jni/CImg.h:63906
"ImageMagick or GraphicsMagick only writes the first image slice.",
cimg_instance,filename);
const unsigned int omode = cimg::exception_mode();
bool is_saved = true;
cimg::exception_mode(0);
try { save_magick(filename); }
catch (CImgException&) {
try { save_imagemagick_external(filename,quality); }
catch (CImgException&) {
try { save_graphicsmagick_external(filename,quality); }
catch (CImgException&) {
is_saved = false;
}
}
}
cimg::exception_mode(omode);
if (!is_saved)
throw CImgIOException(_cimg_instance
"save_other(): Failed to save file '%s'. Format is not natively supported, "
"and no external commands succeeded.",
cimg_instance,
filename);
return *this;
}
//! Serialize a CImg<T> instance into a raw CImg<unsigned char> buffer.
/**
\param is_compressed tells if zlib compression must be used for serialization
(this requires 'cimg_use_zlib' been enabled).
\param header_size Reserve empty bytes as a starting header.
**/
CImg<ucharT> get_serialize(const bool is_compressed=false, const unsigned int header_size=0) const {
return CImgList<T>(*this,true).get_serialize(is_compressed,header_size);
}
// [internal] Return a 40x38 color logo of a 'danger' item.View on GitHub (pinned to f788b534b4)
Solutions
- Install ImageMagick and/or GraphicsMagick so at least one external tool is available.
- Verify cimg::imagemagick_path()/graphicsmagick_path() resolve to working binaries.
- Switch to a format CImg saves natively (PNG/JPEG/BMP/etc.) via save().
- Test the underlying 'convert'/'gm convert' commands manually to find why each tool fails.
- Check ImageMagick policy.xml if the format is silently blocked.
Example fix
// before
img.save_other("out.exr"); // no tool installed -> throws
// after
try { img.save_other("out.exr"); }
catch (CImgIOException&) { img.save_png("out.png"); // native fallback
std::fprintf(stderr, "exr unsupported; wrote png instead\n"); } Defensive patterns
Strategy: try-catch
Validate before calling
bool anyToolAvailable() {
return std::system("magick -version > /dev/null 2>&1") == 0
|| std::system("gm version > /dev/null 2>&1") == 0
|| std::system("medcon -v > /dev/null 2>&1") == 0;
}
// also confirm the target extension maps to a format some tool can write Try / catch
try {
img.save_other(filename);
} catch (CImgIOException& e) {
std::fprintf(stderr, "no writer available: %s", e.what());
img.save_png("output.png"); // native fallback
} Prevention
- Install at least one of ImageMagick/GraphicsMagick in deployment images.
- Restrict save_other() usage to formats you have verified a tool can write.
- Prefer CImg native save() for common formats (PNG/JPEG/BMP).
- Verify tool paths and ImageMagick policy.xml as part of environment setup.
- Smoke-test saving each required format in CI on the actual deployment image.
When it happens
Trigger: Calling save_other(filename) (or generic save() dispatching to it) with a format CImg cannot write natively when: no external tools are installed, all tool invocations fail (wrong paths, policy blocks, unsupported format), or the output file is never produced.
Common situations: Minimal Docker/CI images with neither ImageMagick nor GraphicsMagick installed; exotic formats (e.g. HEIC, medical formats) unsupported by installed tools; paths/env vars for tool locations misconfigured; requesting a format extension no tool recognizes.
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_graphicsmagick_external(): Failed to save file '%s' wit
- save_imagemagick_external(): Failed to save file '%s' with e
- save_medcon_external(): Failed to save file '%s' with extern
- load_png(): Invalid bit depth %u in file '%s'.
- load_png(): Invalid color coding type %u in file '%s'.
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/9175ab9b77ccefd5.
Report an issue: GitHub.