Commit 8f8b77b9 authored by Erdem Karakus's avatar Erdem Karakus

CMS-11395 [Backport 11.2] temporary image won't be deleted on scaling

When original image used instead of scaled image in the scaling
operation, original image file on the file system won't be deleted.

(cherry picked from commit 06025da5)
parent 555e39b7
......@@ -285,10 +285,12 @@ public class ScaleImageOperation extends AbstractImageOperation {
scaledWidth = scaledImage.getWidth();
scaledHeight = scaledImage.getHeight();
// if the scale size equals to the original image size use the image which has the smaller weight
if (scaledOutputStream.toByteArray().length > IOUtils.toByteArray(dataInputStream).length
&& scaledWidth == originalWidth && scaledHeight == originalHeight) {
// if the scaled image dimensions equals to the original image dimensions and
// scaled image weight is bigger than the original image weight, use original image
if (scaledWidth == originalWidth && scaledHeight == originalHeight
&& scaledOutputStream.toByteArray().length > IOUtils.toByteArray(dataInputStream).length) {
scaledData = new AutoDeletingTmpFileInputStream(tmpFile);
deleteTmpFile = false;
} else {
scaledData = new ByteArrayInputStream(scaledOutputStream.toByteArray());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment