{"record":{"id":"720e962c8c328899","repo":"flowable/flowable-engine","slug":"error-while-reading-process-diagram-image-720e96","errorCode":null,"errorMessage":"Error while reading process diagram image.","messagePattern":"Error while reading process diagram image\\.","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramLayoutFactory.java","lineNumber":187,"sourceCode":"\n        DiagramNode diagramBounds = new DiagramNode(\"BPMNDiagram\");\n        diagramBounds.setX(minX);\n        diagramBounds.setY(minY);\n        diagramBounds.setWidth(maxX - minX);\n        diagramBounds.setHeight(maxY - minY);\n        return diagramBounds;\n    }\n\n    protected DiagramNode getDiagramBoundsFromImage(InputStream imageStream) {\n        return getDiagramBoundsFromImage(imageStream, 0, 0);\n    }\n\n    protected DiagramNode getDiagramBoundsFromImage(InputStream imageStream, int offsetTop, int offsetBottom) {\n        BufferedImage image;\n        try {\n            image = ImageIO.read(imageStream);\n        } catch (IOException e) {\n            throw new ActivitiException(\"Error while reading process diagram image.\", e);\n        }\n        DiagramNode diagramBoundsImage = getDiagramBoundsFromImage(image, offsetTop, offsetBottom);\n        return diagramBoundsImage;\n    }\n\n    protected DiagramNode getDiagramBoundsFromImage(BufferedImage image, int offsetTop, int offsetBottom) {\n        int width = image.getWidth();\n        int height = image.getHeight();\n\n        Map<Integer, Boolean> rowIsWhite = new TreeMap<>();\n        Map<Integer, Boolean> columnIsWhite = new TreeMap<>();\n\n        for (int row = 0; row < height; row++) {\n            if (!rowIsWhite.containsKey(row)) {\n                rowIsWhite.put(row, true);\n            }\n            if (row <= offsetTop || row > image.getHeight() - offsetBottom) {\n                rowIsWhite.put(row, true);","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramLayoutFactory.java#L169-L205","documentation":"getDiagramBoundsFromImage reads the process diagram image via ImageIO.read to determine its pixel bounds for offset calculations. If the stream cannot be read or decoded as an image (IOException), an ActivitiException is thrown.","triggerScenarios":"getDiagramBoundsFromImage is called with an InputStream whose content is not a readable image format or whose stream throws IOException during read.","commonSituations":"Passing a corrupt/empty image file; supplying an unsupported image format; stream already consumed by a previous read.","solutions":["Verify the image file is valid and decodable by ImageIO (PNG/JPEG/GIF)","Reset or reopen the InputStream before the call","Check image format support for your JDK (some formats like TIFF need extra libraries)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"try {\n    BufferedImage img = ImageIO.read(new File(imagePath));\n    if (img == null) throw new IllegalStateException(\"Not a decodable image: \" + imagePath);\n} catch (IOException e) { throw new IllegalStateException(\"Unreadable image\", e); }","typeGuard":null,"tryCatchPattern":"try {\n    bounds = factory.getProcessDiagramLayout(bpmnStream, imageStream);\n} catch (org.activiti.engine.ActivitiException e) {\n    if (e.getMessage().contains(\"reading process diagram image\")) {\n        // supply a valid PNG/JPEG stream or skip image-based bounds\n    }\n}","preventionTips":["Verify image files are non-empty and in a JDK-supported format","Reopen the InputStream instead of reusing a consumed one","Keep image assets under version control to avoid corruption"],"tags":["image","io","diagram"],"backgroundTag":"file-read-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}