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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations