ImageInfo info = ensureFormatIsSupported(tmpImageFile, bytes, true);
// In the absence of an exception, tmpImageFile now contains an image
// Word will accept
ContentTypeManager ctm = opcPackage.getContentTypeManager();
// Ensure the relationships part exists
if (sourcePart.getRelationshipsPart() == null) {
RelationshipsPart.createRelationshipsPartForPart(sourcePart);
}
String proposedRelId = sourcePart.getRelationshipsPart().getNextId();
String ext = info.getMimeType().substring(info.getMimeType().indexOf("/") + 1);
// System.out.println(ext);
BinaryPartAbstractImage imagePart =
(BinaryPartAbstractImage) ctm.newPartForContentType(
info.getMimeType(),
createImageName(opcPackage, sourcePart, proposedRelId, ext), null);
log.debug("created part " + imagePart.getClass().getName()
+ " with name " + imagePart.getPartName().toString());