https://issues.apache.org/bugzilla/show_bug.cgi?id=45829

           Summary: HSSFPicture.getImageDimension() fails when DPI of image
                    is zero
           Product: POI
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


Created an attachment (id=22597)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=22597)
Test PNG image with zero DPI

POI version 3.1-FINAL-20080629.

When calling HSSFPicture.resize() for a PNG image that does not specify a DPI
(DPI width and height is zero), HSSFPicture.getImageDimension() method fails
with ArithmeticException (/ by zero).

It seems that in getResolution() the HorizontalPixelSize and VerticalPixelSize
image metadata elements have values of zero if DPI is set to zero in PNG files.
 While this might indicate a problem with the PNG file, failing with / by zero
error is not appropriate as other software can happily load and display these
files.  It would be more appropriate to either fall back to DPI defaults (96
DPI) rather than returning zeroes from this method or have special handling in
getImageDimension() so that DPI is not used if it is zero.

Stack trace:
java.lang.ArithmeticException: / by zero
        at
org.apache.poi.hssf.usermodel.HSSFPicture.getImageDimension(HSSFPicture.java:238)
        at
org.apache.poi.hssf.usermodel.HSSFPicture.getPreferredSize(HSSFPicture.java:120)
        at
org.apache.poi.hssf.usermodel.HSSFPicture.resize(HSSFPicture.java:97)
        ...


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to