{"record":{"id":"68b2788e15f7acc9","repo":"Yalantis/uCrop","slug":"load-webp-does-not-support-animated-webp-s","errorCode":null,"errorMessage":"load_webp(): Does not support animated WebP '%s'.","messagePattern":"load_webp\\(\\): Does not support animated WebP '(.+?)'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":59583,"sourceCode":"      }\n      CImg<ucharT> buffer(data_size);\n      cimg::fread(buffer._data, buffer._width, file);\n      cimg::fclose(file);\n\n      WebPDecoderConfig config;\n      if (!WebPInitDecoderConfig(&config))\n        throw CImgIOException(_cimg_instance\n                              \"load_webp(): Failed to init WebP decoder config.\",\n                              cimg_instance);\n\n      if (WebPGetFeatures(buffer._data, data_size, &config.input)!=VP8_STATUS_OK)\n        throw CImgIOException(_cimg_instance\n                              \"load_webp(): Failed to get image meta info of '%s'.\",\n                              cimg_instance,\n                              filename);\n\n      if (config.input.has_animation)\n        throw CImgIOException(_cimg_instance\n                              \"load_webp(): Does not support animated WebP '%s'.\",\n                              cimg_instance,\n                              filename);\n\n      int width = config.input.width, height = config.input.height;\n      if (config.input.has_alpha) {\n        config.output.colorspace = MODE_RGBA;\n        assign(width,height,1,4);\n      } else {\n        config.output.colorspace = MODE_RGB;\n        assign(width,height,1,3);\n      }\n      if (WebPDecode(buffer._data, data_size, &config)!=VP8_STATUS_OK)\n        throw CImgIOException(_cimg_instance\n                              \"load_webp(): Failed to decode image '%s'.\",\n                              cimg_instance,\n                              filename);\n","sourceCodeStart":59565,"sourceCodeEnd":59601,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L59565-L59601","documentation":"CImg's load_webp() refuses to load animated WebP files. After reading the WebP header via WebPDemux/meta info, it checks config.input.has_animation and throws CImgIOException because CImg only decodes static (single-frame) WebP images. The file itself is valid; the library simply does not support the animated variant.","triggerScenarios":"Calling CImg<T>::load_webp() (or load() on a file auto-detected as WebP) with a .webp file that contains multiple animation frames (WebP mux/animation format).","commonSituations":"Downloading WebP images from the web (ad networks, avatars) which are often animated; processing user-uploaded images saved by modern browsers/tools that default to animated WebP.","solutions":["Convert the file to a static WebP or another format (e.g. with ffmpeg/ffmpeg -i in.webp -frames:v 1 out.webp or cwebp) before loading","Extract the first frame with WebPAnimDecoder or the `webpmux`/`anim_dump` tools, then load that frame","Load the file with an external backend that supports animation, e.g. load_imagemagick_external()/load_graphicsmagick_external()","Pre-detect animated WebP by checking the RIFF/VP8X header (ANIM/ANMF chunks) and skip or handle those files"],"exampleFix":"// before\nimg.load_webp(\"animated.webp\"); // throws CImgIOException\n// after\nif (!is_animated_webp(\"animated.webp\")) {\n  img.load_webp(\"animated.webp\");\n} else {\n  cimg::system(\"ffmpeg -y -i animated.webp -frames:v 1 first_frame.webp\");\n  img.load_webp(\"first_frame.webp\");\n}","handlingStrategy":"validation","validationCode":"bool is_animated_webp(const char* f) {\n  std::ifstream in(f, std::ios::binary);\n  unsigned char hdr[30] = {0};\n  in.read((char*)hdr, 30);\n  if (in.gcount() < 30 || std::memcmp(hdr, \"RIFF\", 4) || std::memcmp(hdr+8, \"WEBP\", 4)) return false;\n  // VP8X extended format: check animation bit\n  if (!std::memcmp(hdr+12, \"VP8X\", 4)) return (hdr[17] & 0x02) != 0;\n  return false;\n}","typeGuard":"bool is_static_webp(const char* filename) { return cimg::is_file(filename) && !is_animated_webp(filename); }","tryCatchPattern":"try {\n  img.load_webp(filename);\n} catch (CImgIOException& e) {\n  // animated webp: extract first frame externally and retry\n  cimg::system(\"ffmpeg -y -i f.webp -frames:v 1 f0.webp\");\n  img.load_webp(\"f0.webp\");\n}","preventionTips":["Check the VP8X animation bit (or run webpinfo) before load_webp","Convert user/web-sourced images to static formats at ingest","Keep bundled libwebp current and handle animation with WebPAnimDecoder explicitly","Prefer built-in loaders with explicit format checks over blind load()"],"tags":["cimg","webp","image-loading","unsupported-format"],"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"}