Bug 56928 - Picture resizing does not work with WMF files
Summary: Picture resizing does not work with WMF files
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.11-dev
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-08 13:51 UTC by Martin Studer
Modified: 2014-09-08 13:51 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Studer 2014-09-08 13:51:59 UTC
Picture resizing does not seem to work with windows meta files (WMF). The following is a reproducible example:

Workbook workbook = new XSSFWorkbook(); // could also use HSSF
Sheet sheet = workbook.createSheet("test");
Name name = workbook.createName();
name.setNameName("test");
name.setRefersToFormula("test!$A$1:$C$6");
        
AreaReference aref = new AreaReference(name.getRefersToFormula());
CellReference topLeft = aref.getFirstCell();
CellReference bottomRight = aref.getLastCell();

int imageType = Workbook.PICTURE_TYPE_WMF;

InputStream is = new FileInputStream(new File("/home/mstuder/test.wmf"));
byte[] bytes = IOUtils.toByteArray(is);
int imageIndex = workbook.addPicture(bytes, imageType);
is.close();

Drawing drawing = sheet.createDrawingPatriarch();
CreationHelper helper = workbook.getCreationHelper();
ClientAnchor anchor = helper.createClientAnchor();
anchor.setRow1(topLeft.getRow());
anchor.setCol1(topLeft.getCol());
anchor.setRow2(bottomRight.getRow() + 1);
anchor.setCol2(bottomRight.getCol() + 1);
anchor.setAnchorType(ClientAnchor.DONT_MOVE_AND_RESIZE);

Picture picture = drawing.createPicture(anchor, imageIndex);
picture.resize();
        
workbook.write(new FileOutputStream(new File("/home/mstuder/test.xlsx")));


When commenting out picture.resize() the picture is added properly with the size of the named range "test". Including picture.resize(), no image is added at all. Picture resizing works fine with other image types such as jpeg and png.