Search in sources :

Example 6 with ImageResizeOptions

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);
}
Also used : ImageTransformationOptions(org.alfresco.repo.content.transform.magick.ImageTransformationOptions) ImageResizeOptions(org.alfresco.repo.content.transform.magick.ImageResizeOptions) Test(org.junit.Test)

Example 7 with ImageResizeOptions

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);
}
Also used : ImageTransformationOptions(org.alfresco.repo.content.transform.magick.ImageTransformationOptions) ImageResizeOptions(org.alfresco.repo.content.transform.magick.ImageResizeOptions) Test(org.junit.Test)

Example 8 with ImageResizeOptions

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);
}
Also used : ImageTransformationOptions(org.alfresco.repo.content.transform.magick.ImageTransformationOptions) ImageResizeOptions(org.alfresco.repo.content.transform.magick.ImageResizeOptions) Test(org.junit.Test)

Example 9 with ImageResizeOptions

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;
}
Also used : ImageResizeOptions(org.alfresco.repo.content.transform.magick.ImageResizeOptions)

Example 10 with 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);
}
Also used : ImageTransformationOptions(org.alfresco.repo.content.transform.magick.ImageTransformationOptions) ImageResizeOptions(org.alfresco.repo.content.transform.magick.ImageResizeOptions)

Aggregations

ImageResizeOptions (org.alfresco.repo.content.transform.magick.ImageResizeOptions)23 ImageTransformationOptions (org.alfresco.repo.content.transform.magick.ImageTransformationOptions)22 Test (org.junit.Test)15 HashMap (java.util.HashMap)6 NodeRef (org.alfresco.service.cmr.repository.NodeRef)6 AbstractContentTransformerTest (org.alfresco.repo.content.transform.AbstractContentTransformerTest)5 PagedSourceOptions (org.alfresco.service.cmr.repository.PagedSourceOptions)5 BaseAlfrescoSpringTest (org.alfresco.util.BaseAlfrescoSpringTest)5 Serializable (java.io.Serializable)4 SWFTransformationOptions (org.alfresco.repo.content.transform.swf.SWFTransformationOptions)4 TemporalSourceOptions (org.alfresco.service.cmr.repository.TemporalSourceOptions)3 TransformationSourceOptions (org.alfresco.service.cmr.repository.TransformationSourceOptions)3 RuntimeExecutableContentTransformerOptions (org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerOptions)2 CropSourceOptions (org.alfresco.service.cmr.repository.CropSourceOptions)2 ThumbnailParentAssociationDetails (org.alfresco.service.cmr.thumbnail.ThumbnailParentAssociationDetails)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1