MNT-22409 single page image previewACS 6.2.2: Legacy transformer with ImageMagick fails to generate multi-page TIFF -> multi-page PDF file preview (#468)

(cherry picked from commit 79c4494ce1)
This commit is contained in:
alandavis
2021-05-17 17:35:57 +01:00
parent 06f2185121
commit df91938304
5 changed files with 53 additions and 12 deletions

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -291,7 +291,8 @@ public abstract class AbstractImageMagickContentTransformerWorker extends Conten
" target extension: " + targetExtension);
}
if (remoteTransformerClientConfigured())
boolean tEngineConfigured = remoteTransformerClientConfigured();
if (tEngineConfigured)
{
transformRemote(reader, writer, options, sourceMimetype, targetMimetype, sourceExtension, targetExtension);
}

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -247,8 +247,8 @@ public class ImageMagickContentTransformerWorker extends AbstractImageMagickCont
}
properties.put(KEY_OPTIONS, commandOptions);
}
properties.put(VAR_SOURCE, sourceFile.getAbsolutePath() +
getSourcePageRange(options, sourceMimetype, targetMimetype));
String sourcePageRange = getSourcePageRange(options, sourceMimetype, targetMimetype);
properties.put(VAR_SOURCE, sourceFile.getAbsolutePath() + sourcePageRange);
properties.put(VAR_TARGET, targetFile.getAbsolutePath());
// execute the statement
@@ -389,6 +389,9 @@ public class ImageMagickContentTransformerWorker extends AbstractImageMagickCont
}
else
{
// The following is a somewhat flawed workaround for the fact that the "pdf" rendition in older
// versions of ACS used a SWFTransformationOptions object rather than a ImageTransformationOptions
// object. See MNT-22409.
if (options.getPageLimit() == 1 || isSingleSourcePageRangeRequired(sourceMimetype, targetMimetype))
{
startPage = "0";
@@ -644,6 +647,9 @@ public class ImageMagickContentTransformerWorker extends AbstractImageMagickCont
}
}
}
// The following is a somewhat flawed workaround for the fact that the "pdf" rendition in older
// versions of ACS used a SWFTransformationOptions object rather than a ImageTransformationOptions
// object. See MNT-22409.
if (options.getPageLimit() == 1 || isSingleSourcePageRangeRequired(sourceMimetype, targetMimetype))
{
return "[0]";

View File

@@ -9,7 +9,9 @@
{"name": "allowEnlargement", "value": true},
{"name": "maintainAspectRatio", "value": true},
{"name": "autoOrient", "value": true},
{"name": "thumbnail", "value": true}
{"name": "thumbnail", "value": true},
{"name": "startPage", "value": "0"},
{"name": "endPage", "value": "0"}
]
},
{
@@ -21,7 +23,9 @@
{"name": "allowEnlargement", "value": false},
{"name": "maintainAspectRatio", "value": true},
{"name": "autoOrient", "value": true},
{"name": "thumbnail", "value": true}
{"name": "thumbnail", "value": true},
{"name": "startPage", "value": "0"},
{"name": "endPage", "value": "0"}
]
},
{
@@ -33,7 +37,9 @@
{"name": "allowEnlargement", "value": false},
{"name": "maintainAspectRatio", "value": true},
{"name": "autoOrient", "value": true},
{"name": "thumbnail", "value": true}
{"name": "thumbnail", "value": true},
{"name": "startPage", "value": "0"},
{"name": "endPage", "value": "0"}
]
},
{
@@ -45,7 +51,9 @@
{"name": "allowEnlargement", "value": false},
{"name": "maintainAspectRatio", "value": true},
{"name": "autoOrient", "value": true},
{"name": "thumbnail", "value": true}
{"name": "thumbnail", "value": true},
{"name": "startPage", "value": "0"},
{"name": "endPage", "value": "0"}
]
},
{
@@ -57,7 +65,9 @@
{"name": "allowEnlargement", "value": false},
{"name": "maintainAspectRatio", "value": true},
{"name": "autoOrient", "value": true},
{"name": "thumbnail", "value": true}
{"name": "thumbnail", "value": true},
{"name": "startPage", "value": "0"},
{"name": "endPage", "value": "0"}
]
},
{

View File

@@ -581,7 +581,7 @@ system.thumbnail.definition.default.timeoutMs=-1
system.thumbnail.definition.default.readLimitTimeMs=-1
system.thumbnail.definition.default.maxSourceSizeKBytes=-1
system.thumbnail.definition.default.readLimitKBytes=-1
system.thumbnail.definition.default.pageLimit=1
system.thumbnail.definition.default.pageLimit=-1
system.thumbnail.definition.default.maxPages=-1
# Max mimetype sizes to create thumbnail icons

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2019 Alfresco Software Limited
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -32,10 +32,13 @@ import org.alfresco.repo.thumbnail.ThumbnailDefinition;
import org.alfresco.repo.thumbnail.ThumbnailRenditionConvertor;
import org.alfresco.service.cmr.rendition.RenditionDefinition;
import org.alfresco.service.cmr.rendition.RenditionService;
import org.alfresco.service.cmr.repository.PagedSourceOptions;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.cmr.repository.TransformationSourceOptions;
import org.alfresco.util.BaseSpringTest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -126,6 +129,27 @@ public class RenditionDefinitionTest extends BaseSpringTest
// than checking transformationOptions is equal to transformationOptions2.
if (!renditionName.equals("pdf") && !renditionName.equals("webpreview"))
{
// MNT-22409: We no longer have system.thumbnail.definition.default.pageLimit=1 as a default.
// It is -1 (unlimited), but to compensate for that the new OOTB renditions defined in
// 0100-baseRenditions now have startPage and endPage transform options. The following code modifies
// the transformationOptions so that they will be the same if there are no bugs.
Collection<TransformationSourceOptions> sourceOptionsList = transformationOptions2.getSourceOptionsList();
if (sourceOptionsList != null && sourceOptionsList.size() == 1)
{
TransformationSourceOptions sourceOptions = sourceOptionsList.iterator().next();
if (sourceOptions instanceof PagedSourceOptions)
{
PagedSourceOptions pagedSourceOptions = (PagedSourceOptions)sourceOptions;
if (pagedSourceOptions.getStartPageNumber() == 1 && pagedSourceOptions.getEndPageNumber() == 1)
{
if (transformationOptions.getSourceOptionsList() == null)
{
transformationOptions.setSourceOptionsList(sourceOptionsList);
}
}
}
}
assertEquals("The TransformationOptions used in transforms for " + renditionName + " should be the same",
transformationOptions.toStringAll(), transformationOptions2.toStringAll());
assertEquals("The transformationOptionsConverter back to the newer format was not the same for " +