{"record":{"id":"7c7c5b088829f500","repo":"Yalantis/uCrop","slug":"save-gif-external-failed-to-save-file-s-with","errorCode":null,"errorMessage":"save_gif_external(): Failed to save file '%s' with external command 'magick/convert'.","messagePattern":"save_gif_external\\(\\): Failed to save file '(.+?)' with external command 'magick/convert'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":68054,"sourceCode":"        else if (frame._spectrum==1) frame.assign(frame.get_resize(-100,-100,1,3),false);\n        else if (frame._spectrum==2)\n          frame.assign(frame.get_resize(-100,-100,1,4).draw_image(0,0,0,2,frame.get_shared_channel(0)),false);\n        frame.save(filename_tmp2);\n      }\n      cimg_snprintf(command,command._width,\"\\\"%s\\\" -delay %u -loop %u -dispose previous\",\n                    cimg::imagemagick_path(),\n                    (unsigned int)std::max(0.f,cimg::round(100/fps)),\n                    nb_loops);\n      CImg<ucharT>::string(command).move_to(filenames,0);\n      cimg_snprintf(command,command._width,\"\\\"%s\\\"\",\n                    CImg<charT>::string(filename)._system_strescape().data());\n      CImg<ucharT>::string(command).move_to(filenames);\n      CImg<charT> _command = filenames>'x';\n      cimg_for(_command,p,char) if (!*p) *p = ' ';\n      _command.back() = 0;\n\n      if (cimg::system(_command,cimg::imagemagick_path())!=0)\n        throw CImgIOException(_cimglist_instance\n                              \"save_gif_external(): Failed to save file '%s' with external command 'magick/convert'.\",\n                              cimglist_instance,\n                              filename);\n      if (!cimg::path_exists(filename))\n        throw CImgIOException(_cimglist_instance\n                              \"save_gif_external(): Failed to save file '%s' with external command 'magick/convert'.\",\n                              cimglist_instance,\n                              filename);\n      cimglist_for_in(*this,1,filenames._width - 1,l) std::remove(filenames[l]);\n      return *this;\n    }\n\n    //! Save list as a YUV image sequence file.\n    /**\n      \\param filename Filename to write data to.\n      \\param chroma_subsampling Type of chroma subsampling. Can be <tt>{ 420 | 422 | 444 }</tt>.\n      \\param is_rgb Tells if the RGB to YUV conversion must be done for saving.\n    **/","sourceCodeStart":68036,"sourceCodeEnd":68072,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L68036-L68072","documentation":"save_gif_external() assembles an ImageMagick 'magick'/'convert' command line from per-frame temp files and runs it via cimg::system(). A nonzero exit status from that external process throws this CImgIOException — the GIF was not written because ImageMagick itself failed.","triggerScenarios":"cimg::system() returns !=0 when executing the imagemagick command: 'magick'/'convert' binary not installed, bad imagemagick_path(), command-line length limits exceeded, or invalid frame files.","commonSituations":"CI containers without ImageMagick; IM6 'convert' vs IM7 'magick' naming differences; very long frame lists exceeding shell/command length limits (common on Android execve limits).","solutions":["Install ImageMagick or set the correct binary via CImg_IMAGEMAGICK_PATH env / cimg::imagemagick_path().","Reduce the number of frames or write to a shorter temp directory to shrink the command line.","Verify the exact ImageMagick invocation manually with the same arguments to see the real error."],"exampleFix":"// before\nlist.save_gif_external(\"anim.gif\"); // fails if ImageMagick absent\n// after\nif (std::system(\"command -v convert >/dev/null\")!=0)\n  throw std::runtime_error(\"ImageMagick not installed\");\nlist.save_gif_external(\"anim.gif\");","handlingStrategy":"fallback","validationCode":"if (std::system(\"command -v magick >/dev/null 2>&1 && command -v convert >/dev/null 2>&1\") != 0) {\n  fprintf(stderr, \"ImageMagick unavailable\\n\");\n  return false;\n}","typeGuard":null,"tryCatchPattern":"try { list.save_gif_external(out); }\ncatch (CImgIOException &e) { /* save frames individually or use a native GIF encoder */ }","preventionTips":["Install ImageMagick in deployment images.","Keep frame counts/temp paths short to avoid command-line limits.","Set imagemagick_path()/env correctly for IM6 vs IM7."],"tags":["gif","imagemagick","external-process"],"backgroundTag":"external-command-failed","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}