private TikaImageExtractingParser(RenderingContext renderingContext) { this.renderingContext = renderingContext; // Our expected types types = new HashSet<MediaType>(); types.add(MediaType.image("bmp")); types.add(MediaType.image("gif")); types.add(MediaType.image("jpg")); types.add(MediaType.image("jpeg")); types.add(MediaType.image("png")); types.add(MediaType.image("tiff")); // Are images going in the same place as the HTML? if (renderingContext.getParamWithDefault(PARAM_IMAGES_SAME_FOLDER, false)) { RenditionLocation location = resolveRenditionLocation( renderingContext.getSourceNode(), renderingContext.getDefinition(), renderingContext.getDestinationNode()); imgFolder = location.getParentRef(); if (logger.isDebugEnabled()) { logger.debug("Using imgFolder: " + imgFolder); } } }
/** * Creates a directory to store the images in. The directory will be a sibling of the rendered * HTML, and named similar to it. Note this is only required if {@link #PARAM_IMAGES_SAME_FOLDER} * is false (the default). */ private NodeRef createImagesDirectory(RenderingContext context) { // It should be a sibling of the HTML in it's eventual location // (not it's current temporary one!) RenditionLocation location = resolveRenditionLocation( context.getSourceNode(), context.getDefinition(), context.getDestinationNode()); NodeRef parent = location.getParentRef(); // Figure out what to call it, based on the HTML node String folderName = getImagesDirectoryName(context); // It is already there? // (eg from when the rendition is being re-run) NodeRef imgFolder = nodeService.getChildByName(parent, ContentModel.ASSOC_CONTAINS, folderName); if (imgFolder != null) return imgFolder; // Create the directory Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); properties.put(ContentModel.PROP_NAME, folderName); imgFolder = nodeService .createNode( parent, ContentModel.ASSOC_CONTAINS, QName.createQName(folderName), ContentModel.TYPE_FOLDER, properties) .getChildRef(); return imgFolder; }