Insert images into excel with POI

How to insert images when outputting excel using POI packages in Java.

try {
    FileInputStream images = new FileInputStream("/path/to/file.png");
    
    final Drawing drawing = sheet.createDrawingPatriarch();
    final ClientAnchor anchor = helper.createClientAnchor();
    anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE );
    final int pictureIndex = workbook.addPicture(
        IOUtils.toByteArray(images),
        Workbook.PICTURE_TYPE_PNG
    );
    anchor.setCol1(1);
    anchor.setRow1(1);
    final Picture picture = drawing.createPicture(anchor, pictureIndex);
    picture.resize(1.0, 1.0);
} catch (Exception ex) {
    ex.printStackTrace();
}

References

poi java