{"record":{"id":"2f2cc28eaee88cfe","repo":"Yalantis/uCrop","slug":"load-gif-external-failed-to-open-file-s","errorCode":null,"errorMessage":"load_gif_external(): Failed to open file '%s'.","messagePattern":"load_gif_external\\(\\): Failed to open file '(.+?)'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":67514,"sourceCode":"    //! Load an image from a video file using the external tool 'ffmpeg' \\newinstance.\n    static CImgList<T> get_load_ffmpeg_external(const char *const filename) {\n      return CImgList<T>().load_ffmpeg_external(filename);\n    }\n\n    //! Load gif file, using ImageMagick or GraphicsMagick's external tools.\n    /**\n      \\param filename Filename to read data from.\n    **/\n    CImgList<T>& load_gif_external(const char *const filename) {\n      if (!filename || !cimg::is_file(filename))\n        throw CImgArgumentException(_cimglist_instance\n                                    \"load_gif_external(): Specified filename is (null) or does not exist.\",\n                                    cimglist_instance);\n      if (!_load_gif_external(filename,false))\n        if (!_load_gif_external(filename,true))\n          try { assign(CImg<T>().load_other(filename)); } catch (CImgException&) { assign(); }\n      if (is_empty())\n        throw CImgIOException(_cimglist_instance\n                              \"load_gif_external(): Failed to open file '%s'.\",\n                              cimglist_instance,filename);\n      return *this;\n    }\n\n    CImgList<T>& _load_gif_external(const char *const filename, const bool use_graphicsmagick=false) {\n      CImg<charT> command(1024), filename_tmp(256), filename_tmp2(256);\n      do {\n        cimg_snprintf(filename_tmp,filename_tmp._width,\"%s%c%s\",\n                      cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());\n        if (use_graphicsmagick) cimg_snprintf(filename_tmp2,filename_tmp2._width,\"%s.png.0\",filename_tmp._data);\n        else cimg_snprintf(filename_tmp2,filename_tmp2._width,\"%s-0.png\",filename_tmp._data);\n      } while (cimg::path_exists(filename_tmp2));\n      if (use_graphicsmagick) cimg_snprintf(command,command._width,\"%s convert \\\"%s\\\" \\\"%s.png\\\"\",\n                                            cimg::graphicsmagick_path(),\n                                            CImg<charT>::string(filename)._system_strescape().data(),\n                                            CImg<charT>::string(filename_tmp)._system_strescape().data());\n      else cimg_snprintf(command,command._width,\"\\\"%s\\\" -coalesce \\\"%s\\\" \\\"%s.png\\\"\",","sourceCodeStart":67496,"sourceCodeEnd":67532,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L67496-L67532","documentation":"load_gif_external() tries GraphicsMagick, then ImageMagick, then CImg's generic load_other() fallback. If all attempts fail, the list stays empty and it throws this CImgIOException. Typically the external convert/magick/gm binary is missing or fails to decode the GIF, and the generic loader cannot handle the file either.","triggerScenarios":"load_gif_external() on a system without ImageMagick/GraphicsMagick installed (or not found at cimg::magick_path()/graphicsmagick_path()), or with a corrupt/unsupported file that also defeats load_other().","commonSituations":"Minimal Docker/CI images lacking ImageMagick; magick_path misconfigured; GIF variants (e.g. huge or malformed frames) rejected by all loaders; Android native builds with no external tools at all.","solutions":["Install ImageMagick (or GraphicsMagick) and ensure cimg::magick_path()/cimg::graphicsmagick_path() resolves to the binary.","Verify with 'magick identify file.gif' (or 'gm identify') that the tools can decode the file.","Pre-decode the GIF to PNG frames with your own tool and load them with load_png, or split animated GIFs beforehand.","Check the file integrity (e.g. 'file x.gif', re-export from an editor) if tools are installed but decoding still fails."],"exampleFix":"// before\nlist.load_gif_external(\"anim.gif\"); // no ImageMagick in container\n\n// after\n// Dockerfile: RUN apt-get install -y imagemagick\ncimg::magick_path(\"/usr/bin/magick\");\nlist.load_gif_external(\"anim.gif\");","handlingStrategy":"fallback","validationCode":"// ensure ImageMagick is available before the external GIF path\nbool magickAvailable() {\n  return cimg::system(\n    CImg<char>::string(cimg::magick_path()) + \" -version\") == 0;\n}","typeGuard":null,"tryCatchPattern":"try {\n  list.load_gif_external(file);\n} catch (CImgIOException&) {\n  // last-resort generic loader or manual pre-decode\n  try { list.assign(CImg<unsigned char>().load_other(file)); }\n  catch (CImgException&) { /* unhandleable */ }\n}","preventionTips":["Install ImageMagick/GraphicsMagick and point cimg::magick_path() at it.","Test 'magick identify file.gif' in your deployment environment.","Pre-convert animated GIFs to PNG frame sequences for environments without external tools."],"tags":["cimg","gif","imagemagick","external-tool","missing-dependency"],"backgroundTag":"missing-dependency","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"}