protected void addViews(List<Map<String, Object>> pictureConversions, String filename, String title) throws IOException { doc.setProperty("dublincore", "title", title); if (pictureConversions != null) { // Use PictureBook Properties for (Map<String, Object> view : pictureConversions) { Integer maxsize; if (view.get("maxsize") == null) { maxsize = MEDIUM_SIZE; } else { maxsize = ((Long) view.get("maxsize")).intValue(); } createPictureimpl((String) view.get("description"), (String) view.get("tag"), (String) view.get("title"), maxsize, filename, width, height, depth, fileContent); } } else { List<PictureView> pictureViews = getImagingService().computeViewsFor(doc, fileContent, getImageInfo(), true); addPictureViews(pictureViews, true); } }
@Override public boolean fillPictureViews(Blob blob, String filename, String title) throws IOException { return fillPictureViews(blob, filename, title, null); }
public void createPictureimpl(String description, String tag, String title, Integer maxsize, String filename, Integer width, Integer height, Integer depth, Blob fileContent) throws IOException { if (fileContent.getFilename() == null) { fileContent.setFilename(filename); } if (maxsize == null) { maxsize = 0; } PictureConversion pictureConversion = new PictureConversion(title, description, tag, maxsize); pictureConversion.setChainId("Image.Blob.Resize"); PictureView view = getImagingService().computeViewFor(fileContent, pictureConversion, getImageInfo(), true); addPictureView(view); }
/** * Attach new picture views with the document * * @since 7.1 */ protected void addPictureViews(List<PictureView> pictureViews, boolean clearPictureViews) { if (clearPictureViews) { clearViews(); } List<Map<String, Serializable>> views = getPictureViews(); for (PictureView pictureView : pictureViews) { views.add(pictureView.asMap()); } doc.setPropertyValue(VIEWS_PROPERTY, (Serializable) views); }
protected void setMetadata() throws IOException { boolean imageInfoUsed = false; ImageInfo imageInfo = getImageInfo(); if (imageInfo != null) { width = imageInfo.getWidth(); imageInfoUsed = true; Map<String, Object> metadata = getImagingService().getImageMetadata(fileContent); description = (String) metadata.get(META_DESCRIPTION); if (!imageInfoUsed) {
/** * Returns the {@link ImageInfo} for the main Blob ({@code fileContent}). * * @since 5.9.5. */ protected ImageInfo getImageInfo() { if (imageInfo == null) { imageInfo = getImagingService().getImageInfo(fileContent); } return imageInfo; }
/** * Add a pictureView to the existing picture views attached with the document * * @since 7.1 */ protected void addPictureView(PictureView view) { List<Map<String, Serializable>> views = getPictureViews(); views.add(view.asMap()); doc.setPropertyValue(VIEWS_PROPERTY, (Serializable) views); }
protected Blob crop(Blob blob, Map<String, Serializable> coords) { try { BlobHolder bh = new SimpleBlobHolder(blob); String type = blob.getMimeType(); Map<String, Serializable> options = new HashMap<>(); options.put(OPTION_CROP_X, coords.get("x")); options.put(OPTION_CROP_Y, coords.get("y")); options.put(OPTION_RESIZE_HEIGHT, coords.get("h")); options.put(OPTION_RESIZE_WIDTH, coords.get("w")); if (!"image/png".equals(type)) { bh = getConversionService().convert(OPERATION_CROP, bh, options); return Blobs.createBlob(bh.getBlob().getStream(), type); } } catch (IOException e) { throw new NuxeoException("Crop failed", e); } return null; }