Bug 57634

Summary: Incorrect picture resizing
Product: POI Reporter: Daniil Lopatin <solid.danil>
Component: SS CommonAssignee: POI Developers List <dev>
Status: RESOLVED DUPLICATE    
Severity: major    
Priority: P2    
Version: 3.11-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Daniil Lopatin 2015-02-25 09:37:46 UTC
After update to poi 3.11, picture resizing works incorrect. It stretches picture by height and width with methods Picture.resize(double) and Picture.resize(double, double) for XSSFPicture.

Steps to reproduce:
1. Load image less by size than target cell.
2. Create anchor and set col1 and row1
3. Put image on anchor
4. Resize it by Picture.resize(). Now we adjusted anchor to image size.
5. Resize it again with Picture.resize(1.0).
6. Write workbook.

What is expected:

Picture with original size.

What is actual:

Picture is stretched by width and height with different scale.



The problem in new method
Dimension org.apache.poi.ss.util.ImageUtils.getDimensionFromAnchor(Picture picture).
Line 231 and 251: w = sheet.getColumnWidthInPixels(col2++); h = getRowHeightInPixels(sheet,row2++); Here we ALWAYS take cell dimension and in next steps add additional sizes based on getDy2 and getDx2.
Comment 1 Nick Burch 2015-02-25 09:40:34 UTC
Are you able to produce a junit unit test showing the problem, and/or a patch to correct the logic?
Comment 2 Andreas Beeker 2015-02-25 14:45:16 UTC
Have you looked into my comment in #55967? (the original issue to image resizing)

If you aren't satisfied with the reasoning, please reopen and continue the discussion there

*** This bug has been marked as a duplicate of bug 55967 ***
Comment 3 Daniil Lopatin 2015-02-25 14:51:35 UTC
Yes, I read your comment and saw what you did.
Have you tried steps to reproduce it which were provided here?

Will provide test or/and patch in process of time.