Bug 43125 - [PATCH] Support for non-bitmap pictures in HSSFWorkbook.getAllPictures()
Summary: [PATCH] Support for non-bitmap pictures in HSSFWorkbook.getAllPictures()
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-FINAL
Hardware: Other other
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
Keywords: PatchAvailable
Depends on:
Reported: 2007-08-14 18:40 UTC by Trejkaz (pen name)
Modified: 2017-02-18 17:59 UTC (History)
0 users

Proposed patch (3.01 KB, patch)
2007-08-14 18:40 UTC, Trejkaz (pen name)
Details | Diff
Proposed patch, v2 (13.78 KB, patch)
2007-08-14 20:27 UTC, Trejkaz (pen name)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Trejkaz (pen name) 2007-08-14 18:40:31 UTC
The support I provided for getting pictures was only getting out the bitmaps. 
The following patch adds support for any kind of image stored in a BLIP.
Comment 1 Trejkaz (pen name) 2007-08-14 18:40:50 UTC
Created attachment 20663 [details]
Proposed patch
Comment 2 Trejkaz (pen name) 2007-08-14 18:48:24 UTC
On second thought it looks like this will need a little more work.  The binary
exposed is in itself not the picture data.  I'll get a better patch in once I've
figured out how this F01A blip works.
Comment 3 Trejkaz (pen name) 2007-08-14 20:27:42 UTC
Created attachment 20666 [details]
Proposed patch, v2

Here's a better version, defines an EscherMetafileBlip class which properly
handles at least EMF.

I can't find the record IDs for WMF and PICT anywhere.	If someone could create
a file with those types of BLIP inside, I would be grateful, but even if I put
a WMF into the document on my copy of Word, I seem to get an EMF.
Comment 4 David Fisher 2007-08-14 20:40:13 UTC
I'm pretty sure that Yegor will have a look at this patch some time next week,
he'll have an example of a PICT and maybe an EMF.
Comment 5 David Fisher 2007-08-14 20:41:15 UTC
I meant WMF, not EMF.
Comment 6 Yegor Kozlov 2007-08-26 09:01:34 UTC
I reviewed and committed the patch. The code works fine for EMF and WMF but 
fails on PICT.
See how I read PICT in org.apache.poi.hslf.blip.PICT. The header is different 
from WMF/EMF and you 
should skip different number of bytes before inflating the data.  

How did you test your code? Would you provide a unit test? 

I provided two xls files:

Created on Windows. Contains JPEG, PNG, EMF and WMF. 

Created on MAC. Contains JPEG, PNG and PICT. 

The point is that MS Office for MAC automatically converts WMF and EMF into 
PICT and vise versa - 
MS Office for Windows automatically stores PICT as WMF. So there are two test 

All the pictures can be found in 

Add your test logic in this file. It already contains tests for JPEG and PNG. 

Comment 7 Trejkaz (pen name) 2007-08-26 16:18:58 UTC
I'll get onto writing that unit test as soon as I'm done with my current round
of changes.  At the moment my own code is in disarray from working on another
Comment 8 Andy Oliver 2007-09-11 08:01:00 UTC
make sure this doesn't break the existing stuff for drawing Escher images in
Comment 9 Dominik Stadler 2017-02-18 17:59:31 UTC
I think most of these changes are applied since some time and there was updated support for EMF/WMF in some areas lately (more exctraction than HSSF directly though), however I don't think this is still applicable and thus won't be applied unless someone comes up with an up-to-date set of changes.