Bug 57634 - Incorrect picture resizing
Summary: Incorrect picture resizing
Status: RESOLVED DUPLICATE of bug 55967
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 3.11-FINAL
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2015-02-25 09:37 UTC by Daniil Lopatin
Modified: 2015-02-25 14:51 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
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.