{"record":{"id":"b418a9dd07456a92","repo":"docling-project/docling","slug":"decoded-image-exceeds-size-limit-of-self-max-imag","errorCode":null,"errorMessage":"Decoded image exceeds size limit of {self.max_image_data_base64_bytes} bytes.","messagePattern":"Decoded image exceeds size limit of (.+?) bytes\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"docling/backend/utils/image_resource_loader.py","lineNumber":253,"sourceCode":"            if content_length and int(content_length) > max_size:\n                raise ValueError(f\"Resource size exceeds limit: {content_length} bytes\")\n\n            chunks = []\n            total_size = 0\n            for chunk in response.iter_content(chunk_size=8192):\n                if chunk:\n                    total_size += len(chunk)\n                    if total_size > max_size:\n                        raise ValueError(\"Downloaded data exceeds size limit\")\n                    chunks.append(chunk)\n\n            return b\"\".join(chunks)\n        elif src_loc.startswith(\"data:\"):\n            encoded_data = re.sub(r\"^data:image/.+;base64,\", \"\", src_loc)\n            decoded_data = base64.b64decode(encoded_data)\n\n            if len(decoded_data) > self.max_image_data_base64_bytes:\n                raise ValueError(\n                    f\"Decoded image exceeds size limit of {self.max_image_data_base64_bytes} bytes.\"\n                )\n\n            return decoded_data\n\n        if not self.enable_local_fetch:\n            raise OperationNotAllowed(\n                \"Fetching local resources is only allowed when set explicitly. \"\n                \"Set options.enable_local_fetch=True.\"\n            )\n\n        # Require base_path for directory confinement (validation done in resolve_relative_path)\n        if not base_path:\n            raise OperationNotAllowed(\n                f\"Local file access requires base_path for directory confinement: '{src_loc}'\"\n            )\n\n        if os.path.isfile(src_loc) and os.access(src_loc, os.R_OK):","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/backend/utils/image_resource_loader.py#L235-L271","documentation":"A data: URI embedded image was base64-decoded and its decoded size exceeds max_image_data_base64_bytes (default 20 MiB, from backend options). This bounds memory blow-up from inline images in HTML/Markdown. The whole data URI is already in the source document, so decoding happened locally.","triggerScenarios":"Input HTML/Markdown contains <img src=\"data:image/...;base64,...\"> whose decoded payload is larger than options.max_image_data_base64_bytes (the loader receives it from HtmlBackend/MdBackend options).","commonSituations":"Single-file HTML exports (e.g. 'save as complete webpage', Jupyter/Pandas exports) inlining print-resolution screenshots; a security policy lowering the default; WYSIWYG editors embedding pasted screenshots as data URIs.","solutions":["Raise max_image_data_base64_bytes in your pipeline/backend options if the inline images are legitimate.","Pre-process the input to extract data URIs into separate image files and reference them via local paths with enable_local_fetch + base_path.","Strip or downsample oversized inline images before conversion if you don't need them."],"exampleFix":"# before\nhtml_opts = HtmlPipelineOptions()  # default 20 MiB inline image cap\n\n# after\nhtml_opts = HtmlPipelineOptions()\nhtml_opts.max_image_data_base64_bytes = 100 * 1024 * 1024","handlingStrategy":"validation","validationCode":"import base64, re\n\ndef inline_image_within_limit(data_uri: str, max_decoded: int) -> bool:\n    m = re.match(r\"^data:image/.+;base64,(.*)$\", data_uri, re.S)\n    if not m:\n        return True\n    b64 = m.group(1)\n    approx = len(b64) * 3 // 4\n    return approx <= max_decoded","typeGuard":null,"tryCatchPattern":"try:\n    data = loader.load_image_data(src, base_path)\nexcept ValueError as e:\n    if \"size limit\" in str(e):\n        logger.warning(\"inline image too large, skipping\")\n    else:\n        raise","preventionTips":["Set max_image_data_base64_bytes from your real corpus statistics before batch runs.","Preprocess single-file HTML exports: extract data URIs to files and reference them locally.","Estimate decoded size as len(base64)*3/4 when auditing documents."],"tags":["images","size-limit","base64","html","markdown"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}