zxing/zxing · error · IOException

Invalid base64 data URI

Error message

Invalid base64 data URI

What it means

Error "Invalid base64 data URI" thrown in zxing/zxing.

Source

Thrown at javase/src/main/java/com/google/zxing/client/j2se/ImageReader.java:68

    }
    return result;
  }
  
  public static BufferedImage readDataURIImage(URI uri) throws IOException {
    String uriString = uri.getSchemeSpecificPart();
    if (!uriString.startsWith("image/")) {
      throw new IOException("Unsupported data URI MIME type");
    }
    int base64Start = uriString.indexOf(BASE64TOKEN);
    if (base64Start < 0) {
      throw new IOException("Unsupported data URI encoding");
    }
    String base64Data = uriString.substring(base64Start + BASE64TOKEN.length());
    byte[] imageBytes;
    try {
      imageBytes = Base64.getDecoder().decode(base64Data);
    } catch (IllegalArgumentException iae) {
      throw new IOException("Invalid base64 data URI", iae);
    }
    return ImageIO.read(new ByteArrayInputStream(imageBytes));
  }

}

View on GitHub (pinned to 19aa2d8254)

Solutions

  1. Provide correctly base64-encoded data in the data URI.
  2. Re-encode the payload with a standard base64 encoder and retry.

When it happens

Trigger: Thrown at javase/src/main/java/com/google/zxing/client/j2se/ImageReader.java:68 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zxing/zxing@19aa2d8254 (2026-08-14). Data as JSON: /api/errors/282b9a8ad0632fee. Report an issue: GitHub.