if (pathInfo.getWidth() > 0 && pathInfo.getHeight() > 0) { if (pathInfo.isNoStretch()) { float targetAspect = (float) pathInfo.getWidth() / (float) pathInfo.getHeight(); if (targetAspect < originalAspect) { targetH = Math.min(pathInfo.getHeight(), sourceH); // pathInfo.getHeight() > sourceH ? sourceH : pathInfo.getHeight(); targetW = (int) Math.ceil(targetH * targetAspect); cropX = (int) Math.ceil((sourceW - (sourceH * targetAspect)) / 2); targetW = Math.min(pathInfo.getWidth(), sourceW); // pathInfo.getWidth() > sourceW ? sourceW : pathInfo.getWidth(); targetH = (int) Math.ceil(targetW / targetAspect); cropY = (int) Math.ceil((sourceH - (sourceW / targetAspect)) / 2); targetH = pathInfo.getHeight(); targetW = pathInfo.getWidth(); } else if (pathInfo.getWidth() > 0) { targetW = (pathInfo.isNoStretch() && pathInfo.getWidth() > sourceW) ? sourceW : pathInfo.getWidth(); targetH = (int) (sourceH * ((float) targetW / (float) sourceW)); } else { targetH = (pathInfo.isNoStretch() && pathInfo.getHeight() > sourceH) ? sourceH : pathInfo.getHeight(); targetW = (int) (sourceW * ((float) targetH / (float) sourceH)); pathInfo.getFileName(), cropX, cropY, sourceW, sourceH, targetW, targetH);
log.trace("getStaticContentFile: {}", file); final ImageUtils.StaticContentPathInfo pathInfo = new ImageUtils.StaticContentPathInfo(path); binaryMeta = dynamicMetaRetriever.getBinaryMetaByURL(_prependFullUrlIfNeeded(pathInfo.getFileName(), requestDto.getBaseUrl())); if (binaryMeta == null) { throw new StaticContentNotFoundException("No binary meta found for: [" + publicationId + "] " + pathInfo.getFileName()); if (componentMeta == null) { throw new StaticContentNotFoundException("No meta meta found for: [" + publicationId + "] " + pathInfo.getFileName());
@Override protected DefaultContentProvider.StaticContentFile getStaticContentFile(File file, ImageUtils.StaticContentPathInfo pathInfo, int publicationId) throws ContentProviderException, IOException { BinaryMeta binaryMeta; WebComponentMetaFactory factory = new WebComponentMetaFactoryImpl(publicationId); ComponentMeta componentMeta; int itemId; synchronized (LOCK) { binaryMeta = dynamicMetaRetriever.getBinaryMetaByURL(prependFullUrlIfNeeded(pathInfo.getFileName())); if (binaryMeta == null) { throw new StaticContentNotFoundException("No binary meta found for: [" + publicationId + "] " + pathInfo.getFileName()); } itemId = (int) binaryMeta.getURI().getItemId(); componentMeta = factory.getMeta(itemId); if (componentMeta == null) { throw new StaticContentNotFoundException("No meta meta found for: [" + publicationId + "] " + pathInfo.getFileName()); } } long componentTime = componentMeta.getLastPublicationDate().getTime(); if (isToBeRefreshed(file, componentTime)) { BinaryData binaryData = binaryContentRetriever.getBinary(publicationId, itemId, binaryMeta.getVariantId()); LOG.debug("Writing binary content to file: {}", file); writeToFile(file, pathInfo, binaryData.getBytes()); } else { LOG.debug("File does not need to be refreshed: {}", file); } return new StaticContentFile(file, binaryMeta.getType()); }