Yalantis/uCrop · error · CImgIOException

load_webp(): Does not support animated WebP '%s'.

Error message

load_webp(): Does not support animated WebP '%s'.

What it means

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.

Source

Thrown at ucrop/src/main/jni/CImg.h:59583

      }
      CImg<ucharT> buffer(data_size);
      cimg::fread(buffer._data, buffer._width, file);
      cimg::fclose(file);

      WebPDecoderConfig config;
      if (!WebPInitDecoderConfig(&config))
        throw CImgIOException(_cimg_instance
                              "load_webp(): Failed to init WebP decoder config.",
                              cimg_instance);

      if (WebPGetFeatures(buffer._data, data_size, &config.input)!=VP8_STATUS_OK)
        throw CImgIOException(_cimg_instance
                              "load_webp(): Failed to get image meta info of '%s'.",
                              cimg_instance,
                              filename);

      if (config.input.has_animation)
        throw CImgIOException(_cimg_instance
                              "load_webp(): Does not support animated WebP '%s'.",
                              cimg_instance,
                              filename);

      int width = config.input.width, height = config.input.height;
      if (config.input.has_alpha) {
        config.output.colorspace = MODE_RGBA;
        assign(width,height,1,4);
      } else {
        config.output.colorspace = MODE_RGB;
        assign(width,height,1,3);
      }
      if (WebPDecode(buffer._data, data_size, &config)!=VP8_STATUS_OK)
        throw CImgIOException(_cimg_instance
                              "load_webp(): Failed to decode image '%s'.",
                              cimg_instance,
                              filename);

View on GitHub (pinned to f788b534b4)

Solutions

  1. 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
  2. Extract the first frame with WebPAnimDecoder or the `webpmux`/`anim_dump` tools, then load that frame
  3. Load the file with an external backend that supports animation, e.g. load_imagemagick_external()/load_graphicsmagick_external()
  4. Pre-detect animated WebP by checking the RIFF/VP8X header (ANIM/ANMF chunks) and skip or handle those files

Example fix

// before
img.load_webp("animated.webp"); // throws CImgIOException
// after
if (!is_animated_webp("animated.webp")) {
  img.load_webp("animated.webp");
} else {
  cimg::system("ffmpeg -y -i animated.webp -frames:v 1 first_frame.webp");
  img.load_webp("first_frame.webp");
}
Defensive patterns

Strategy: validation

Validate before calling

bool is_animated_webp(const char* f) {
  std::ifstream in(f, std::ios::binary);
  unsigned char hdr[30] = {0};
  in.read((char*)hdr, 30);
  if (in.gcount() < 30 || std::memcmp(hdr, "RIFF", 4) || std::memcmp(hdr+8, "WEBP", 4)) return false;
  // VP8X extended format: check animation bit
  if (!std::memcmp(hdr+12, "VP8X", 4)) return (hdr[17] & 0x02) != 0;
  return false;
}

Type guard

bool is_static_webp(const char* filename) { return cimg::is_file(filename) && !is_animated_webp(filename); }

Try / catch

try {
  img.load_webp(filename);
} catch (CImgIOException& e) {
  // animated webp: extract first frame externally and retry
  cimg::system("ffmpeg -y -i f.webp -frames:v 1 f0.webp");
  img.load_webp("f0.webp");
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

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


AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08). Data as JSON: /api/errors/68b2788e15f7acc9. Report an issue: GitHub.