/** * Check whether any resize or crop param has been set. * * @return */ default boolean hasResizeParams() { return getHeight() != null || getWidth() != null || getCropMode() != null; }
/** * Return the image size. * * @return Image size or null when width or height are missing */ default Point getSize() { Integer w = getWidth(); Integer h = getHeight(); if (w == null || h == null) { return null; } return new Point(w, h); }
/** * Check whether all required crop parameters have been set. * * @param options * @return Fluent API */ default ImageManipulationParameters validateLimits(ImageManipulatorOptions options) { if (getWidth() != null && options.getMaxWidth() != null && options.getMaxWidth() > 0 && getWidth() > options.getMaxWidth()) { throw error(BAD_REQUEST, "image_error_width_limit_exceeded", String.valueOf(options.getMaxWidth()), String.valueOf(getWidth())); } if (getHeight() != null && options.getMaxHeight() != null && options.getMaxHeight() > 0 && getHeight() > options.getMaxHeight()) { throw error(BAD_REQUEST, "image_error_height_limit_exceeded", String.valueOf(options.getMaxHeight()), String.valueOf(getHeight())); } return this; }
/** * Generate cache key. * * @return */ default String getCacheKey() { StringBuilder builder = new StringBuilder(); if (getRect() != null) { builder.append("rect" + getRect().toString()); } if (getCropMode() != null) { builder.append("crop" + getCropMode()); } if (getWidth() != null) { builder.append("rw" + getWidth()); } if (getHeight() != null) { builder.append("rh" + getHeight()); } if (getFocalPoint() != null) { builder.append("fp" + getFocalPoint().toString()); } if (getFocalPointDebug()) { builder.append("fpdebug"); } if (getFocalPointZoom() != null) { builder.append("fpz" + getFocalPointZoom()); } return builder.toString(); }
@Override public MeshRequest<NodeResponse> transformNodeBinaryField(String projectName, String nodeUuid, String languageTag, String version, String fieldKey, ImageManipulationParameters parameters) { Objects.requireNonNull(projectName, "projectName must not be null"); Objects.requireNonNull(nodeUuid, "nodeUuid must not be null"); Objects.requireNonNull(languageTag, "language must not be null"); Objects.requireNonNull(version, "version must not be null"); Objects.requireNonNull(fieldKey, "field key must not be null"); BinaryFieldTransformRequest transformRequest = new BinaryFieldTransformRequest(); transformRequest.setCropRect(parameters.getRect()); transformRequest.setWidth(parameters.getWidth()); transformRequest.setHeight(parameters.getHeight()); transformRequest.setLanguage(languageTag).setVersion(version); return prepareRequest(POST, "/" + encodeSegment(projectName) + "/nodes/" + nodeUuid + "/binaryTransform/" + fieldKey, NodeResponse.class, transformRequest); }
Integer pWidth = parameters.getWidth();