You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2008/09/18 02:15:12 UTC

DO NOT REPLY [Bug 45829] New: HSSFPicture.getImageDimension() fails when DPI of image is zero

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: dev@poi.apache.org
        ReportedBy: prunge@onaustralia.com.au


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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 45829] HSSFPicture.getImageDimension() fails when DPI of image is zero

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45829





--- Comment #1 from Peter Runge <pr...@onaustralia.com.au>  2008-09-17 17:37:42 PST ---
Created an attachment (id=22598)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=22598)
Patch for HSSFPicture.java


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 45829] HSSFPicture.getImageDimension() fails when DPI of image is zero

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45829


Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #3 from Yegor Kozlov <ye...@dinom.ru>  2008-09-18 03:28:44 PST ---
Fixed in r696622

Yegor


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 45829] HSSFPicture.getImageDimension() fails when DPI of image is zero

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45829


Peter Runge <pr...@onaustralia.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |prunge@onaustralia.com.au




--- Comment #2 from Peter Runge <pr...@onaustralia.com.au>  2008-09-17 17:38:48 PST ---
Created patch for HSSFPicture.java against
trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java.

Added zero checking in getImageDimension() before division and using defaults
if zero is found.


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org