{"record":{"id":"a969d6d94aa5848d","repo":"docusealco/docuseal","slug":"unsupported-image-bitmap-format","errorCode":null,"errorMessage":"Unsupported image bitmap format","messagePattern":"Unsupported image bitmap format","errorType":"exception","errorClass":"Pdfium::PdfiumError","httpStatus":null,"severity":"warning","filePath":"lib/pdfium.rb","lineNumber":1458,"sourceCode":"        bitmap = extract_image_bitmap(object_ptr)\n        pixel_rects = image_pixel_rects(matrix, bitmap[:width], bitmap[:height], overlapping)\n\n        next if pixel_rects.empty?\n\n        jpeg = yield(bitmap, pixel_rects)\n\n        load_image_jpeg(object_ptr, jpeg) if jpeg\n      end\n    end\n\n    def extract_image_bitmap(object_ptr)\n      bitmap_ptr = Pdfium.FPDFImageObj_GetBitmap(object_ptr)\n\n      raise PdfiumError, 'Failed to get image bitmap' if bitmap_ptr.nil? || bitmap_ptr.null?\n\n      format, bands = BITMAP_FORMAT_BANDS[Pdfium.FPDFBitmap_GetFormat(bitmap_ptr)]\n\n      raise PdfiumError, 'Unsupported image bitmap format' if format.nil?\n\n      image_width = Pdfium.FPDFBitmap_GetWidth(bitmap_ptr)\n      image_height = Pdfium.FPDFBitmap_GetHeight(bitmap_ptr)\n      stride = Pdfium.FPDFBitmap_GetStride(bitmap_ptr)\n\n      data = Pdfium.FPDFBitmap_GetBuffer(bitmap_ptr).read_bytes(stride * image_height)\n\n      row_size = image_width * bands\n\n      data = Array.new(image_height) { |row| data.byteslice(row * stride, row_size) }.join if stride != row_size\n\n      { data:, width: image_width, height: image_height, bands:, format: }\n    ensure\n      Pdfium.FPDFBitmap_Destroy(bitmap_ptr) if bitmap_ptr && !bitmap_ptr.null?\n    end\n\n    def image_pixel_rects(matrix, image_width, image_height, rect_bounds)\n      a, b, c, d, e, f = matrix","sourceCodeStart":1440,"sourceCodeEnd":1476,"githubUrl":"https://github.com/docusealco/docuseal/blob/004a22c1c88109c7ba0b567df011a8cb13894001/lib/pdfium.rb#L1440-L1476","documentation":"Raised by extract_image_bitmap when the bitmap's reported format is outside BITMAP_FORMAT_BANDS, which maps only the FPDFBitmap codes 1-4 (gray, bgr, bgrx, bgra). FPDFBitmap_Unknown (0) and any other code yield a nil format and trigger this raise. In practice pdfium reports unknown for images it could not decode into a standard pixel layout, such as 1-bit stencil/image masks.","triggerScenarios":"Same redaction pipeline as error 38, but the bitmap exists while its pixel format is unknown: monochrome image masks, stencil masks used for signatures/stamps, partially decoded streams.","commonSituations":"Scanned documents with monochrome image masks; signature and stamp overlays stored as stencil masks.","solutions":["Rescue per image and fall back to covering the overlap with an opaque drawn rect","Rasterize or normalize the PDF (ghostscript) before redaction","Update libpdfium","Treat unknown-format images as not pixel-redactable and log them for review"],"exampleFix":"# before\npage.redact(rects) { |bitmap, pr| pixel_blacken(bitmap, pr) }\n\n# after\nbegin\n  page.redact(rects) { |bitmap, pr| pixel_blacken(bitmap, pr) }\nrescue Pdfium::PdfiumError => e\n  raise unless e.message == 'Unsupported image bitmap format'\n  page.redact(rects) # draw-only fallback for this page's images\nend","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"begin\n  page.redact(rects) { |bitmap, pr| pixel_blacken(bitmap, pr) }\nrescue Pdfium::PdfiumError => e\n  raise unless e.message == 'Unsupported image bitmap format'\n  page.redact(rects) # cover-rect fallback for stencil-mask images\nend","preventionTips":["Expect stencil/image-mask content in signatures and stamps; it rarely decodes to a standard bitmap","Pair every pixel-level redaction with the drawn-rect guarantee","Keep a corpus of mask-heavy PDFs in the redaction test suite"],"tags":["pdfium","redaction","images","unsupported-format","ruby"],"backgroundTag":"unsupported-image-format","analyzedSha":"004a22c1c88109c7ba0b567df011a8cb13894001","analyzedAt":"2026-08-21T13:38:23.343Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}