Created attachment 37995 [details] PowerPoint with slide, which has a uncopiable picture Any slide import for pictures fails, if the user edited the picture color using Powerpoint. In our case the slide contained a colored picture, which was edited to show as grey (Picture Color -> Color Saturation -> 0%) An sample presentation and code will be uploaded with this ticket. ---------------------------------------------------------------------------- Test code: import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.apache.poi.xslf.usermodel.XSLFSlide; import org.springframework.core.io.ClassPathResource; import java.io.ByteArrayOutputStream; class Scratch { public static void main(String[] args) throws Exception { XMLSlideShow targetPresentation = new XMLSlideShow(); XSLFSlide targetPresentationSlide = targetPresentation.createSlide(); XMLSlideShow sourcePresentation = new XMLSlideShow(new ClassPathResource("POI_Blip_bug.pptx").getInputStream()); XSLFSlide sourceSlide = sourcePresentation.getSlides().get(0); targetPresentationSlide.getSlideMaster().importContent(sourceSlide.getSlideMaster()); targetPresentationSlide.getSlideLayout().importContent(sourceSlide.getSlideLayout()); targetPresentationSlide.importContent(sourceSlide); targetPresentation.write(new ByteArrayOutputStream()); } } -------------------------------------------------------------------------------- Exception in thread "main" java.lang.ClassCastException: class org.apache.poi.ooxml.POIXMLDocumentPart cannot be cast to class org.apache.poi.xslf.usermodel.XSLFPictureData (org.apache.poi.ooxml.POIXMLDocumentPart and org.apache.poi.xslf.usermodel.XSLFPictureData are in unnamed module of loader 'app') at org.apache.poi.xslf.usermodel.XSLFSheet.importBlip(XSLFSheet.java:651) at org.apache.poi.xslf.usermodel.XSLFPictureShape.copy(XSLFPictureShape.java:385) at org.apache.poi.xslf.usermodel.XSLFSheet.wipeAndReinitialize(XSLFSheet.java:455) at org.apache.poi.xslf.usermodel.XSLFSheet.importContent(XSLFSheet.java:434) at org.apache.poi.xslf.usermodel.XSLFSlide.importContent(XSLFSlide.java:293)
I had a quick look and there appear to be 2 images - 1 is ok and the other is not (rId2 is ok, rId3 is not) the first one is a jpeg, the second one is this Name: /ppt/media/hdphoto1.wdp - Content Type: image/vnd.ms-photo I suspect that POI does not support this file format.
XSLFRelation _table has mappings for relation types - it does not support this one: http://schemas.microsoft.com/office/2007/relationships/hdphoto
I added basic support for hdphoto images - r1892653 - I don't know a great deal about the XLSF code base so I'm happy for other devs to review this change and to revert it if it is the wrong approach.
Possibly, next set of problem with wdp images is getting the dimensions - we have custom classes in https://github.com/apache/poi/tree/trunk/poi/src/main/java/org/apache/poi/sl/image -- the one that is used by default is the bitmap map but it looks like it will default the dimensions if the image data is not parseable.