When the image is damaged, the length and width value of the image is 0, and the scale may change to INFINITY during calculation, causing the program to loop endlessly package org.apache.poi.hssf.usermodel; @Override public void resize(double scaleX, double scaleY) { HSSFClientAnchor anchor = getClientAnchor(); anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE); HSSFClientAnchor pref = getPreferredSize(scaleX,scaleY); int row2 = anchor.getRow1() + (pref.getRow2() - pref.getRow1()); int col2 = anchor.getCol1() + (pref.getCol2() - pref.getCol1()); anchor.setCol2((short)col2); // anchor.setDx1(0); anchor.setDx2(pref.getDx2()); anchor.setRow2(row2); // anchor.setDy1(0); anchor.setDy2(pref.getDy2()); }
I added r1897406 as a starting point
We might want to consider setting a max number of iterations in ImageUtils.setPreferredSize