Search in sources :

Example 1 with ImageResizeOptions

use of org.alfresco.repo.content.transform.magick.ImageResizeOptions in project alfresco-repository by Alfresco.

the class ThumbnailRenditionConvertor method convert.

public ThumbnailDefinition convert(RenditionDefinition renditionDefinition) {
    ThumbnailDefinition thDefn = new ThumbnailDefinition();
    Map<String, Serializable> params = renditionDefinition.getParameterValues();
    // parameters common to all the built-in thumbnail definitions
    Serializable mimeTypeParam = params.get(AbstractRenderingEngine.PARAM_MIME_TYPE);
    thDefn.setMimetype((String) mimeTypeParam);
    thDefn.setName(renditionDefinition.getRenditionName().getLocalName());
    Serializable placeHolderResourcePathParam = params.get(AbstractRenderingEngine.PARAM_PLACEHOLDER_RESOURCE_PATH);
    if (placeHolderResourcePathParam != null) {
        thDefn.setPlaceHolderResourcePath((String) placeHolderResourcePathParam);
    }
    TransformationOptions transformationOptions = null;
    Serializable flashVersion = renditionDefinition.getParameterValue(ReformatRenderingEngine.PARAM_FLASH_VERSION);
    if (flashVersion != null) {
        // Thumbnails based on SWFTransformationOptions
        transformationOptions = new SWFTransformationOptions();
        SWFTransformationOptions swfTranOpts = (SWFTransformationOptions) transformationOptions;
        swfTranOpts.setFlashVersion((String) flashVersion);
    } else {
        // Thumbnails based on ImageTransformationOptions
        transformationOptions = new ImageTransformationOptions();
        ImageTransformationOptions imgTrOpts = (ImageTransformationOptions) transformationOptions;
        ImageResizeOptions resizeOptions = new ImageResizeOptions();
        Serializable xsize = renditionDefinition.getParameterValue(ImageRenderingEngine.PARAM_RESIZE_WIDTH);
        if (xsize != null) {
            resizeOptions.setWidth(((Integer) xsize).intValue());
        }
        Serializable ysize = renditionDefinition.getParameterValue(ImageRenderingEngine.PARAM_RESIZE_HEIGHT);
        if (ysize != null) {
            resizeOptions.setHeight(((Integer) ysize).intValue());
        }
        Serializable maintainAspectRatio = renditionDefinition.getParameterValue(ImageRenderingEngine.PARAM_MAINTAIN_ASPECT_RATIO);
        if (maintainAspectRatio != null) {
            resizeOptions.setMaintainAspectRatio((Boolean) maintainAspectRatio);
        }
        Serializable resizeToThumbnail = renditionDefinition.getParameterValue(ImageRenderingEngine.PARAM_RESIZE_TO_THUMBNAIL);
        if (resizeToThumbnail != null) {
            resizeOptions.setResizeToThumbnail((Boolean) resizeToThumbnail);
        }
        Serializable allowEnlargement = renditionDefinition.getParameterValue(ImageRenderingEngine.PARAM_ALLOW_ENLARGEMENT);
        if (allowEnlargement != null) {
            resizeOptions.setAllowEnlargement((Boolean) allowEnlargement);
        }
        imgTrOpts.setResizeOptions(resizeOptions);
    }
    thDefn.setTransformationOptions(transformationOptions);
    TransformationOptionLimits limits = transformationOptions.getLimits();
    Serializable v = params.get(OPT_TIMEOUT_MS);
    if (v != null) {
        limits.setTimeoutMs((Long) v);
    }
    v = params.get(OPT_READ_LIMIT_TIME_MS);
    if (v != null) {
        limits.setReadLimitTimeMs((Long) v);
    }
    v = params.get(OPT_MAX_SOURCE_SIZE_K_BYTES);
    if (v != null) {
        limits.setMaxSourceSizeKBytes((Long) v);
    }
    v = params.get(OPT_READ_LIMIT_K_BYTES);
    if (v != null) {
        limits.setReadLimitKBytes((Long) v);
    }
    v = params.get(OPT_MAX_PAGES);
    if (v != null) {
        limits.setMaxPages((Integer) v);
    }
    v = params.get(OPT_PAGE_LIMIT);
    if (v != null) {
        limits.setPageLimit((Integer) v);
    }
    return thDefn;
}
Also used : Serializable(java.io.Serializable) TransformationOptionLimits(org.alfresco.service.cmr.repository.TransformationOptionLimits) SWFTransformationOptions(org.alfresco.repo.content.transform.swf.SWFTransformationOptions) ImageTransformationOptions(org.alfresco.repo.content.transform.magick.ImageTransformationOptions) ImageResizeOptions(org.alfresco.repo.content.transform.magick.ImageResizeOptions) SWFTransformationOptions(org.alfresco.repo.content.transform.swf.SWFTransformationOptions) ImageTransformationOptions(org.alfresco.repo.content.transform.magick.ImageTransformationOptions) TransformationOptions(org.alfresco.service.cmr.repository.TransformationOptions)

Example 2 with ImageResizeOptions

use of org.alfresco.repo.content.transform.magick.ImageResizeOptions in project alfresco-repository by Alfresco.

the class TransformationOptionsConverterTest method testImageTransformationOptionsResizeNoEnlargementOrAspectRatio.

@Test
public // Checks we do what was in the legacy ImageMagickContentTransformerWorker
void testImageTransformationOptionsResizeNoEnlargementOrAspectRatio() {
    ImageTransformationOptions oldOptions = new ImageTransformationOptions();
    oldOptions.setAutoOrient(false);
    ImageResizeOptions imageResizeOptions = new ImageResizeOptions();
    imageResizeOptions.setAllowEnlargement(false);
    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=false], autoOrient=false]]", "allowEnlargement=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 3 with ImageResizeOptions

use of org.alfresco.repo.content.transform.magick.ImageResizeOptions in project alfresco-repository by Alfresco.

the class TransformationOptionsConverterTest method testImageTransformationOptionsResizeWidthHeight.

@Test
public // Checks we do what was in the legacy ImageMagickContentTransformerWorker
void testImageTransformationOptionsResizeWidthHeight() {
    ImageTransformationOptions oldOptions = new ImageTransformationOptions();
    oldOptions.setAutoOrient(false);
    ImageResizeOptions imageResizeOptions = new ImageResizeOptions();
    imageResizeOptions.setAllowEnlargement(false);
    imageResizeOptions.setMaintainAspectRatio(false);
    imageResizeOptions.setWidth(18);
    imageResizeOptions.setHeight(15);
    oldOptions.setResizeOptions(imageResizeOptions);
    assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_PNG, "ImageTransformationOptions [commandOptions=, " + "resizeOptions=ImageResizeOptions [width=18, height=15, maintainAspectRatio=false, " + "percentResize=false, resizeToThumbnail=false, allowEnlargement=false], autoOrient=false]]", "allowEnlargement=false " + "maintainAspectRatio=false " + "resizeHeight=15 " + "resizeWidth=18 " + "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 4 with ImageResizeOptions

use of org.alfresco.repo.content.transform.magick.ImageResizeOptions in project alfresco-repository by Alfresco.

the class TransformationOptionsConverterTest method testCompositeReformatAndResizeRendition.

@Test
public void testCompositeReformatAndResizeRendition() {
    ImageTransformationOptions oldOptions = new ImageTransformationOptions();
    ImageResizeOptions imageResizeOptions = new ImageResizeOptions();
    imageResizeOptions.setHeight(30);
    imageResizeOptions.setWidth(20);
    oldOptions.setResizeOptions(imageResizeOptions);
    PagedSourceOptions pagedSourceOptions = new PagedSourceOptions();
    pagedSourceOptions.setStartPageNumber(1);
    pagedSourceOptions.setEndPageNumber(1);
    oldOptions.addSourceOptions(pagedSourceOptions);
    assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_JPEG, "ImageTransformationOptions [commandOptions=, resizeOptions=" + "ImageResizeOptions [width=20, height=30, maintainAspectRatio=true, percentResize=false, " + "resizeToThumbnail=false, allowEnlargement=true], autoOrient=true], " + "sourceOptions={ PagedSourceOptionsPagedSourceOptions {1, 1}} ]", "alphaRemove=true " + "autoOrient=true " + "endPage=0 " + "resizeHeight=30 " + "resizeWidth=20 " + "startPage=0 " + "timeout=-1 ", true);
}
Also used : ImageTransformationOptions(org.alfresco.repo.content.transform.magick.ImageTransformationOptions) ImageResizeOptions(org.alfresco.repo.content.transform.magick.ImageResizeOptions) PagedSourceOptions(org.alfresco.service.cmr.repository.PagedSourceOptions) Test(org.junit.Test)

Example 5 with ImageResizeOptions

use of org.alfresco.repo.content.transform.magick.ImageResizeOptions in project alfresco-repository by Alfresco.

the class TransformationOptionsConverterTest method testImageTransformationOptionsResizeNoEnlargement.

@Test
public // Checks we do what was in the legacy ImageMagickContentTransformerWorker
void testImageTransformationOptionsResizeNoEnlargement() {
    ImageTransformationOptions oldOptions = new ImageTransformationOptions();
    oldOptions.setAutoOrient(false);
    ImageResizeOptions imageResizeOptions = new ImageResizeOptions();
    imageResizeOptions.setAllowEnlargement(false);
    oldOptions.setResizeOptions(imageResizeOptions);
    assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_PNG, "ImageTransformationOptions [commandOptions=, " + "resizeOptions=ImageResizeOptions [width=-1, height=-1, maintainAspectRatio=true, " + "percentResize=false, resizeToThumbnail=false, allowEnlargement=false], autoOrient=false]]", "allowEnlargement=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)

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