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 2016/04/08 20:55:36 UTC

[Bug 59290] New: EMF images embedded in excel spreadsheet are returned much smaller the actual file image

https://bz.apache.org/bugzilla/show_bug.cgi?id=59290

            Bug ID: 59290
           Summary: EMF images embedded in excel spreadsheet are returned
                    much smaller the actual file image
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: jbjhschiff@msn.com

No matter how I try to get the picture data (byte array) it is always MUCH
smaller then what is actual image embedded in the excel file for EMF images. I
know this is fact because I took an Excel file (say X.xlsx)  made a copy of
this file and renamed it it to X.zip.  Open the archive and went to the
\xl\media\ folder and the embedded original image files are listed in their
full original size and resolutions.  For example one emf image had a size of
804,036 bytes.  If I call the getData on the picture programmatically using the
below code the byteArray is a much smaller, for that same image for example it
was 129KB instead of 804KB.  The image is a valid image just much lower quality
to the point that I really can't use it.  Is there some hidden scaling down of
EMI images? If so can I control this?  


InputStream inp = new FileInputStream(xlsxFilename);
Workbook wb = WorkbookFactory.create(inp);
XSSFSheet sheet = (XSSFSheet) wb.getSheetAt(0);

for (XSSFShape shape : sheet.getDrawingPatriarch().getShapes()) {
       XSSFPicture picture = (XSSFPicture) shape;
       byte[] imageBytes = picture.getPictureData().getData();
.....
       }

-- 
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


[Bug 59290] EMF images embedded in excel spreadsheet are returned much smaller the actual file image

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

Barry <jb...@msn.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |3.14-FINAL
                 OS|                            |All

-- 
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


[Bug 59290] EMF images embedded in excel spreadsheet are returned much smaller the actual file image

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

--- Comment #5 from Andreas Beeker <ki...@apache.org> ---
yes ... the files extracted by POI vs. opening the .xlsx as .zip have the same
size. If unsure, add another example .xlsx!

-- 
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


[Bug 59290] EMF images embedded in excel spreadsheet are returned much smaller the actual file image

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

--- Comment #2 from Andreas Beeker <ki...@apache.org> ---
Created attachment 33745
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33745&action=edit
example file with emf picture

-- 
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


[Bug 59290] EMF images embedded in excel spreadsheet are returned much smaller the actual file image

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

--- Comment #1 from Barry <jb...@msn.com> ---
By the way it was using Office 2016

-- 
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


[Bug 59290] EMF images embedded in excel spreadsheet are returned much smaller the actual file image

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

Andreas Beeker <ki...@apache.org> changed:

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

--- Comment #3 from Andreas Beeker <ki...@apache.org> ---
It's always a pity when a bug entry is not accompanied by an example file.

So I've made up one myself (via Office 20169 ... and it works ... with the
following code


@Test
public void emftest() throws IOException {
    InputStream inp = new FileInputStream("emftest.xlsx");
    XSSFWorkbook wb = new XSSFWorkbook(inp);
    XSSFSheet sheet = wb.getSheetAt(0);
    for (XSSFShape shape : sheet.getDrawingPatriarch().getShapes()) {
        XSSFPicture picture = (XSSFPicture) shape;
        byte[] imageBytes = picture.getPictureData().getData();
        FileOutputStream fos = new FileOutputStream("bla.emf");
        fos.write(imageBytes);
        fos.close();
    }
    wb.close();
    inp.close();
}

-- 
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


[Bug 59290] EMF images embedded in excel spreadsheet are returned much smaller the actual file image

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

--- Comment #4 from Barry <jb...@msn.com> ---
I did not say it did not work. i said the returned file is not the full
size/resolution as the original and the quality is often un-usable. Are you
saying the this does not happen with you>

-- 
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