use of org.alfresco.repo.content.transform.magick.ImageResizeOptions in project alfresco-repository by Alfresco.
the class TransformationOptionsConverterTest method testImageTransformationOptionsResizePercent.
@Test
public // Checks we do what was in the legacy ImageMagickContentTransformerWorker
void testImageTransformationOptionsResizePercent() {
ImageTransformationOptions oldOptions = new ImageTransformationOptions();
oldOptions.setAutoOrient(false);
ImageResizeOptions imageResizeOptions = new ImageResizeOptions();
imageResizeOptions.setAllowEnlargement(false);
imageResizeOptions.setMaintainAspectRatio(false);
imageResizeOptions.setPercentResize(true);
oldOptions.setResizeOptions(imageResizeOptions);
assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_PNG, "ImageTransformationOptions [commandOptions=, " + "resizeOptions=ImageResizeOptions [width=-1, height=-1, maintainAspectRatio=false, " + "percentResize=true, resizeToThumbnail=false, allowEnlargement=false], autoOrient=false]]", "allowEnlargement=false " + "maintainAspectRatio=false " + "resizePercentage=true " + "timeout=-1 ", true);
}
use of org.alfresco.repo.content.transform.magick.ImageResizeOptions in project alfresco-repository by Alfresco.
the class TransformationOptionsConverterTest method testImageTransformationOptionsResizeThumbnnail.
@Test
public // Checks we do what was in the legacy ImageMagickContentTransformerWorker
void testImageTransformationOptionsResizeThumbnnail() {
ImageTransformationOptions oldOptions = new ImageTransformationOptions();
oldOptions.setAutoOrient(false);
ImageResizeOptions imageResizeOptions = new ImageResizeOptions();
imageResizeOptions.setAllowEnlargement(false);
imageResizeOptions.setMaintainAspectRatio(false);
imageResizeOptions.setResizeToThumbnail(true);
oldOptions.setResizeOptions(imageResizeOptions);
assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_PNG, "ImageTransformationOptions [commandOptions=, " + "resizeOptions=ImageResizeOptions [width=-1, height=-1, maintainAspectRatio=false, " + "percentResize=false, resizeToThumbnail=true, allowEnlargement=false], autoOrient=false]]", "allowEnlargement=false " + "maintainAspectRatio=false " + "thumbnail=true " + "timeout=-1 ", true);
}
use of org.alfresco.repo.content.transform.magick.ImageResizeOptions in project alfresco-repository by Alfresco.
the class TransformationOptionsConverterTest method testImageTransformationOptionsResizeNoAspectRatio.
@Test
public // Checks we do what was in the legacy ImageMagickContentTransformerWorker
void testImageTransformationOptionsResizeNoAspectRatio() {
ImageTransformationOptions oldOptions = new ImageTransformationOptions();
oldOptions.setAutoOrient(false);
ImageResizeOptions imageResizeOptions = new ImageResizeOptions();
imageResizeOptions.setMaintainAspectRatio(false);
oldOptions.setResizeOptions(imageResizeOptions);
assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_PNG, "ImageTransformationOptions [commandOptions=, " + "resizeOptions=ImageResizeOptions [width=-1, height=-1, maintainAspectRatio=false, " + "percentResize=false, resizeToThumbnail=false, allowEnlargement=true], autoOrient=false]]", "maintainAspectRatio=false " + "timeout=-1 ", true);
}
use of org.alfresco.repo.content.transform.magick.ImageResizeOptions in project alfresco-repository by Alfresco.
the class ImageRenderingEngine method getImageResizeOptions.
private ImageResizeOptions getImageResizeOptions(RenderingContext context) {
int newHeight = context.getIntegerParam(PARAM_RESIZE_WIDTH, -1);
int newWidth = context.getIntegerParam(PARAM_RESIZE_HEIGHT, -1);
if (newHeight == -1 && newWidth == -1) {
// Image is not being resized!
return null;
}
boolean isPercentResize = context.getParamWithDefault(PARAM_IS_PERCENT_RESIZE, false);
boolean maintainAspectRatio = context.getParamWithDefault(PARAM_MAINTAIN_ASPECT_RATIO, false);
boolean allowEnlargement = context.getParamWithDefault(PARAM_ALLOW_ENLARGEMENT, true);
ImageResizeOptions imageResizeOptions = new ImageResizeOptions();
imageResizeOptions.setMaintainAspectRatio(maintainAspectRatio);
imageResizeOptions.setWidth(newHeight);
imageResizeOptions.setHeight(newWidth);
imageResizeOptions.setPercentResize(isPercentResize);
imageResizeOptions.setAllowEnlargement(allowEnlargement);
return imageResizeOptions;
}
use of org.alfresco.repo.content.transform.magick.ImageResizeOptions in project alfresco-repository by Alfresco.
the class ImageRenderingEngine method getTransformOptionsImpl.
@Override
protected TransformationOptions getTransformOptionsImpl(TransformationOptions options, RenderingContext context) {
options.setSourceNodeRef(context.getSourceNode());
ImageTransformationOptions imageTransformationOptions = (ImageTransformationOptions) options;
String commandOptions = context.getCheckedParam(PARAM_COMMAND_OPTIONS, String.class);
ImageResizeOptions imageResizeOptions = getImageResizeOptions(context);
boolean autoOrient = context.getParamWithDefault(PARAM_AUTO_ORIENTATION, true);
imageTransformationOptions.setResizeOptions(imageResizeOptions);
imageTransformationOptions.setAutoOrient(autoOrient);
if (commandOptions != null) {
imageTransformationOptions.setCommandOptions(commandOptions);
}
return super.getTransformOptionsImpl(options, context);
}
Aggregations