{"record":{"id":"9175ab9b77ccefd5","repo":"Yalantis/uCrop","slug":"save-other-failed-to-save-file-s-format-is","errorCode":null,"errorMessage":"save_other(): Failed to save file '%s'. Format is not natively supported, and no external commands succeeded.","messagePattern":"save_other\\(\\): Failed to save file '(.+?)'\\. Format is not natively supported, and no external commands succeeded\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":63906,"sourceCode":"                   \"ImageMagick or GraphicsMagick only writes the first image slice.\",\n                   cimg_instance,filename);\n\n      const unsigned int omode = cimg::exception_mode();\n      bool is_saved = true;\n      cimg::exception_mode(0);\n      try { save_magick(filename); }\n      catch (CImgException&) {\n        try { save_imagemagick_external(filename,quality); }\n        catch (CImgException&) {\n          try { save_graphicsmagick_external(filename,quality); }\n          catch (CImgException&) {\n            is_saved = false;\n          }\n        }\n      }\n      cimg::exception_mode(omode);\n      if (!is_saved)\n        throw CImgIOException(_cimg_instance\n                              \"save_other(): Failed to save file '%s'. Format is not natively supported, \"\n                              \"and no external commands succeeded.\",\n                              cimg_instance,\n                              filename);\n      return *this;\n    }\n\n    //! Serialize a CImg<T> instance into a raw CImg<unsigned char> buffer.\n    /**\n       \\param is_compressed tells if zlib compression must be used for serialization\n       (this requires 'cimg_use_zlib' been enabled).\n       \\param header_size Reserve empty bytes as a starting header.\n    **/\n    CImg<ucharT> get_serialize(const bool is_compressed=false, const unsigned int header_size=0) const {\n      return CImgList<T>(*this,true).get_serialize(is_compressed,header_size);\n    }\n\n    // [internal] Return a 40x38 color logo of a 'danger' item.","sourceCodeStart":63888,"sourceCodeEnd":63924,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L63888-L63924","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nimg.save_other(\"out.exr\"); // no tool installed -> throws\n// after\ntry { img.save_other(\"out.exr\"); }\ncatch (CImgIOException&) { img.save_png(\"out.png\"); // native fallback\n  std::fprintf(stderr, \"exr unsupported; wrote png instead\\n\"); }","handlingStrategy":"try-catch","validationCode":"bool anyToolAvailable() {\n  return std::system(\"magick -version > /dev/null 2>&1\") == 0\n      || std::system(\"gm version > /dev/null 2>&1\") == 0\n      || std::system(\"medcon -v > /dev/null 2>&1\") == 0;\n}\n// also confirm the target extension maps to a format some tool can write","typeGuard":null,"tryCatchPattern":"try {\n  img.save_other(filename);\n} catch (CImgIOException& e) {\n  std::fprintf(stderr, \"no writer available: %s\", e.what());\n  img.save_png(\"output.png\"); // native fallback\n}","preventionTips":["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."],"tags":["io","external-command","unsupported-format","image-save"],"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"}