diff --git a/changes.xml b/changes.xml index ab06745f..0a14e75d 100644 --- a/changes.xml +++ b/changes.xml @@ -38,6 +38,10 @@ Dynamic Media with OpenAPI: Do not enable support for remote assets by default. Since general availability the related configuration services not longer protected by a feature flag, so the feature has to be enabled explicitly via OSGi configuration.
Breaking change: You can enable support for remote assets by setting "Remote Assets" to true in the "wcm.io Media Handler Dynamic Media with OpenAPI Support" OSGi configuration. ]]> + + Breaking change: You can disable this behavior by setting "Set Image Quality" to false in the "wcm.io Media Handler Dynamic Media Support" OSGi configuration. If disabled, the default image quality setting configured in Dynamic Media is used for all images. + ]]> Eliminate dependency to Commons Lang 2. diff --git a/src/main/java/io/wcm/handler/mediasource/ngdm/impl/ImageQualityPercentage.java b/src/main/java/io/wcm/handler/media/impl/ImageQualityPercentage.java similarity index 94% rename from src/main/java/io/wcm/handler/mediasource/ngdm/impl/ImageQualityPercentage.java rename to src/main/java/io/wcm/handler/media/impl/ImageQualityPercentage.java index 779bc07b..348d17b0 100644 --- a/src/main/java/io/wcm/handler/mediasource/ngdm/impl/ImageQualityPercentage.java +++ b/src/main/java/io/wcm/handler/media/impl/ImageQualityPercentage.java @@ -17,7 +17,7 @@ * limitations under the License. * #L% */ -package io.wcm.handler.mediasource.ngdm.impl; +package io.wcm.handler.media.impl; import org.jetbrains.annotations.NotNull; @@ -25,7 +25,7 @@ import io.wcm.handler.media.spi.MediaHandlerConfig; /** - * Sanitizes SEO names for usage in context of Next Gen. Dynamic Media + * Gets image quality for current media request, with fallback to default quality. */ public final class ImageQualityPercentage { diff --git a/src/main/java/io/wcm/handler/mediasource/dam/impl/DamContext.java b/src/main/java/io/wcm/handler/mediasource/dam/impl/DamContext.java index 704fa1dc..391731ab 100644 --- a/src/main/java/io/wcm/handler/mediasource/dam/impl/DamContext.java +++ b/src/main/java/io/wcm/handler/mediasource/dam/impl/DamContext.java @@ -35,13 +35,13 @@ import io.wcm.handler.media.Dimension; import io.wcm.handler.media.MediaArgs; +import io.wcm.handler.media.impl.ImageQualityPercentage; import io.wcm.handler.media.spi.MediaHandlerConfig; import io.wcm.handler.mediasource.dam.impl.dynamicmedia.DynamicMediaSupportService; import io.wcm.handler.mediasource.dam.impl.dynamicmedia.ImageProfile; import io.wcm.handler.mediasource.dam.impl.dynamicmedia.NamedDimension; import io.wcm.handler.mediasource.dam.impl.weboptimized.WebOptimizedImageDeliveryParams; import io.wcm.handler.mediasource.dam.impl.weboptimized.WebOptimizedImageDeliveryService; -import io.wcm.handler.mediasource.ngdm.impl.ImageQualityPercentage; /** * Context objects require in DAM support implementation. @@ -163,6 +163,14 @@ public boolean isDynamicMediaValidateSmartCropRenditionSizes() { return dynamicMediaSupportService.isValidateSmartCropRenditionSizes(); } + /** + * @return Whether to control image quality for lossy output formats for each media request via 'qlt' URL parameter + * (instead of relying on default setting within Dynamic Media). + */ + public boolean isDynamicMediaSetImageQuality() { + return dynamicMediaSupportService.isSetImageQuality(); + } + /** * @return Dynamic media reply image size limit */ diff --git a/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaPath.java b/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaPath.java index 467e4723..e3a24171 100644 --- a/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaPath.java +++ b/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaPath.java @@ -31,6 +31,7 @@ import io.wcm.handler.media.CropDimension; import io.wcm.handler.media.Dimension; import io.wcm.handler.media.format.Ratio; +import io.wcm.handler.media.impl.ImageQualityPercentage; import io.wcm.handler.mediasource.dam.impl.DamContext; import io.wcm.wcm.commons.contenttype.ContentType; @@ -126,15 +127,8 @@ private DynamicMediaPath() { logResult(damContext, ""); return null; } - result.append("%3A").append(smartCropDef.getName()).append("?") - .append("wid=").append(dimension.getWidth()).append("&") - .append("hei=").append(dimension.getHeight()).append("&") - // cropping/width/height is pre-calculated to fit with original ratio, make sure there are no 1px background lines visible - .append("fit=stretch"); - if (isPNG(damContext)) { - // if original image is PNG image, make sure alpha channel is preserved - result.append("&fmt=png-alpha"); - } + result.append("%3A").append(smartCropDef.getName()).append("?"); + appendWidthHeigtFormatQuality(result, dimension, damContext); logResult(damContext, result); return result.toString(); } @@ -147,6 +141,12 @@ private DynamicMediaPath() { if (rotation != null) { result.append("rotate=").append(rotation).append("&"); } + appendWidthHeigtFormatQuality(result, dimension, damContext); + logResult(damContext, result); + return result.toString(); + } + + private static void appendWidthHeigtFormatQuality(@NotNull StringBuilder result, @NotNull Dimension dimension, @NotNull DamContext damContext) { result.append("wid=").append(dimension.getWidth()).append("&") .append("hei=").append(dimension.getHeight()).append("&") // cropping/width/height is pre-calculated to fit with original ratio, make sure there are no 1px background lines visible @@ -155,8 +155,10 @@ private DynamicMediaPath() { // if original image is PNG image, make sure alpha channel is preserved result.append("&fmt=png-alpha"); } - logResult(damContext, result); - return result.toString(); + else if (damContext.isDynamicMediaSetImageQuality()) { + // it not PNG lossy format is used, apply image quality setting + result.append("&qlt=").append(ImageQualityPercentage.getAsInteger(damContext.getMediaArgs(), damContext.getMediaHandlerConfig())); + } } private static void logResult(@NotNull DamContext damContext, @NotNull CharSequence result) { diff --git a/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaSupportService.java b/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaSupportService.java index 78aa7729..655eb7d6 100644 --- a/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaSupportService.java +++ b/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaSupportService.java @@ -63,6 +63,12 @@ public interface DynamicMediaSupportService { @NotNull Dimension getImageSizeLimit(); + /** + * @return Whether to control image quality for lossy output formats for each media request via 'qlt' URL parameter + * (instead of relying on default setting within Dynamic Media). + */ + boolean isSetImageQuality(); + /** * Get image profile. * @param profilePath Full profile path diff --git a/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaSupportServiceImpl.java b/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaSupportServiceImpl.java index d33de2cc..d06db22f 100644 --- a/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaSupportServiceImpl.java +++ b/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaSupportServiceImpl.java @@ -105,6 +105,11 @@ public class DynamicMediaSupportServiceImpl implements DynamicMediaSupportServic description = "The configured height value for 'Reply Image Size Limit'.") long imageSizeLimitHeight() default 2000; + @AttributeDefinition( + name = "Set Image Quality", + description = "Control image quality for lossy output formats for each media request via 'qlt' URL parameter (instead of relying on default setting within Dynamic Media).") + boolean setImageQuality() default true; + } @Reference @@ -118,6 +123,7 @@ public class DynamicMediaSupportServiceImpl implements DynamicMediaSupportServic private boolean disableAemFallback; private boolean validateSmartCropRenditionSizes; private Dimension imageSizeLimit; + private boolean setImageQuality; private static final String SERVICEUSER_SUBSERVICE = "dynamic-media-support"; private static final Pattern DAM_PATH_PATTERN = Pattern.compile("^/content/dam(/.*)?$"); @@ -132,6 +138,7 @@ private void activate(Config config) { this.disableAemFallback = config.disableAemFallback(); this.validateSmartCropRenditionSizes = config.validateSmartCropRenditionSizes(); this.imageSizeLimit = new Dimension(config.imageSizeLimitWidth(), config.imageSizeLimitHeight()); + this.setImageQuality = config.setImageQuality(); if (this.enabled) { log.info("DynamicMediaSupport: enabled={}, capabilityEnabled={}, capabilityDetection={}, " @@ -174,6 +181,11 @@ public boolean isValidateSmartCropRenditionSizes() { return this.imageSizeLimit; } + @Override + public boolean isSetImageQuality() { + return setImageQuality; + } + @Override public @Nullable ImageProfile getImageProfile(@NotNull String profilePath) { try (ResourceResolver resourceResolver = resourceResolverFactory diff --git a/src/main/java/io/wcm/handler/mediasource/ngdm/NextGenDynamicMediaRendition.java b/src/main/java/io/wcm/handler/mediasource/ngdm/NextGenDynamicMediaRendition.java index 1bb25133..9287371f 100644 --- a/src/main/java/io/wcm/handler/mediasource/ngdm/NextGenDynamicMediaRendition.java +++ b/src/main/java/io/wcm/handler/mediasource/ngdm/NextGenDynamicMediaRendition.java @@ -37,7 +37,7 @@ import io.wcm.handler.media.UriTemplate; import io.wcm.handler.media.UriTemplateType; import io.wcm.handler.media.format.MediaFormat; -import io.wcm.handler.mediasource.ngdm.impl.ImageQualityPercentage; +import io.wcm.handler.media.impl.ImageQualityPercentage; import io.wcm.handler.mediasource.ngdm.impl.MediaArgsDimension; import io.wcm.handler.mediasource.ngdm.impl.NextGenDynamicMediaBinaryUrlBuilder; import io.wcm.handler.mediasource.ngdm.impl.NextGenDynamicMediaContext; diff --git a/src/main/java/io/wcm/handler/mediasource/ngdm/NextGenDynamicMediaUriTemplate.java b/src/main/java/io/wcm/handler/mediasource/ngdm/NextGenDynamicMediaUriTemplate.java index 2f0d36a8..155239d2 100644 --- a/src/main/java/io/wcm/handler/mediasource/ngdm/NextGenDynamicMediaUriTemplate.java +++ b/src/main/java/io/wcm/handler/mediasource/ngdm/NextGenDynamicMediaUriTemplate.java @@ -25,7 +25,7 @@ import io.wcm.handler.media.MediaNameConstants; import io.wcm.handler.media.UriTemplate; import io.wcm.handler.media.UriTemplateType; -import io.wcm.handler.mediasource.ngdm.impl.ImageQualityPercentage; +import io.wcm.handler.media.impl.ImageQualityPercentage; import io.wcm.handler.mediasource.ngdm.impl.MediaArgsDimension; import io.wcm.handler.mediasource.ngdm.impl.NextGenDynamicMediaContext; import io.wcm.handler.mediasource.ngdm.impl.NextGenDynamicMediaImageDeliveryParams; diff --git a/src/test/java/io/wcm/handler/mediasource/ngdm/impl/ImageQualityPercentageTest.java b/src/test/java/io/wcm/handler/media/impl/ImageQualityPercentageTest.java similarity index 97% rename from src/test/java/io/wcm/handler/mediasource/ngdm/impl/ImageQualityPercentageTest.java rename to src/test/java/io/wcm/handler/media/impl/ImageQualityPercentageTest.java index 71109e64..09d80a29 100644 --- a/src/test/java/io/wcm/handler/mediasource/ngdm/impl/ImageQualityPercentageTest.java +++ b/src/test/java/io/wcm/handler/media/impl/ImageQualityPercentageTest.java @@ -17,7 +17,7 @@ * limitations under the License. * #L% */ -package io.wcm.handler.mediasource.ngdm.impl; +package io.wcm.handler.media.impl; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.when; diff --git a/src/test/java/io/wcm/handler/media/impl/MediaHandlerImplEnd2EndDynamicMediaSmartCropTest.java b/src/test/java/io/wcm/handler/media/impl/MediaHandlerImplEnd2EndDynamicMediaSmartCropTest.java index 062c8c00..177a77bb 100644 --- a/src/test/java/io/wcm/handler/media/impl/MediaHandlerImplEnd2EndDynamicMediaSmartCropTest.java +++ b/src/test/java/io/wcm/handler/media/impl/MediaHandlerImplEnd2EndDynamicMediaSmartCropTest.java @@ -102,8 +102,8 @@ void testValidSmartCroppedRenditionAndWidths() { List renditions = List.copyOf(media.getRenditions()); assertEquals(2, renditions.size()); - assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A4-3?wid=80&hei=60&fit=stretch", renditions.get(0).getUrl()); - assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A4-3?wid=40&hei=30&fit=stretch", renditions.get(1).getUrl()); + assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A4-3?wid=80&hei=60&fit=stretch&qlt=85", renditions.get(0).getUrl()); + assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A4-3?wid=40&hei=30&fit=stretch&qlt=85", renditions.get(1).getUrl()); } @Test @@ -118,9 +118,9 @@ void testValidSmartCroppedRenditionAndWidths_DisableValidateSmartCropRenditionSi List renditions = List.copyOf(media.getRenditions()); assertEquals(3, renditions.size()); - assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A4-3?wid=100&hei=75&fit=stretch", renditions.get(0).getUrl()); - assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A4-3?wid=80&hei=60&fit=stretch", renditions.get(1).getUrl()); - assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A4-3?wid=40&hei=30&fit=stretch", renditions.get(2).getUrl()); + assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A4-3?wid=100&hei=75&fit=stretch&qlt=85", renditions.get(0).getUrl()); + assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A4-3?wid=80&hei=60&fit=stretch&qlt=85", renditions.get(1).getUrl()); + assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A4-3?wid=40&hei=30&fit=stretch&qlt=85", renditions.get(2).getUrl()); } @Test @@ -144,7 +144,7 @@ void testValidSmartCroppedRendition_OnlyRatio() { List renditions = List.copyOf(media.getRenditions()); assertEquals(1, renditions.size()); - assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A4-3?wid=80&hei=60&fit=stretch", renditions.get(0).getUrl()); + assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A4-3?wid=80&hei=60&fit=stretch&qlt=85", renditions.get(0).getUrl()); } @Test @@ -154,7 +154,7 @@ void testValidSmartCroppedRenditionOnlyRatio_MatchingOriginalRatio() { List renditions = List.copyOf(media.getRenditions()); assertEquals(1, renditions.size()); - assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A16-10?wid=120&hei=75&fit=stretch", renditions.get(0).getUrl()); + assertEquals("https://dummy.scene7.com/is/image/DummyFolder/test%3A16-10?wid=120&hei=75&fit=stretch&qlt=85", renditions.get(0).getUrl()); } @Test diff --git a/src/test/java/io/wcm/handler/media/impl/MediaHandlerImplImageFileTypesEnd2EndDynamicMediaTest.java b/src/test/java/io/wcm/handler/media/impl/MediaHandlerImplImageFileTypesEnd2EndDynamicMediaTest.java index 1d18d13c..9298c4e2 100644 --- a/src/test/java/io/wcm/handler/media/impl/MediaHandlerImplImageFileTypesEnd2EndDynamicMediaTest.java +++ b/src/test/java/io/wcm/handler/media/impl/MediaHandlerImplImageFileTypesEnd2EndDynamicMediaTest.java @@ -49,7 +49,7 @@ boolean isCreateAssetWithDynamicMediaMetadata() { void testAsset_JPEG_Original() { Asset asset = createSampleAsset("/filetype/sample.jpg", ContentType.JPEG); buildAssertMedia(asset, 100, 50, - "https://dummy.scene7.com/is/image/DummyFolder/sample.jpg?wid=100&hei=50&fit=stretch", + "https://dummy.scene7.com/is/image/DummyFolder/sample.jpg?wid=100&hei=50&fit=stretch&qlt=85", ContentType.JPEG); } @@ -74,7 +74,7 @@ void testAsset_JPEG_Original_ContentDisposition() { void testAsset_JPEG_Rescale() { Asset asset = createSampleAsset("/filetype/sample.jpg", ContentType.JPEG); buildAssertMedia_Rescale(asset, 80, 40, - "https://dummy.scene7.com/is/image/DummyFolder/sample.jpg?wid=80&hei=40&fit=stretch", + "https://dummy.scene7.com/is/image/DummyFolder/sample.jpg?wid=80&hei=40&fit=stretch&qlt=85", ContentType.JPEG); } @@ -83,7 +83,7 @@ void testAsset_JPEG_Rescale() { void testAsset_JPEG_AutoCrop() { Asset asset = createSampleAsset("/filetype/sample.jpg", ContentType.JPEG); buildAssertMedia_AutoCrop(asset, 50, 50, - "https://dummy.scene7.com/is/image/DummyFolder/sample.jpg?crop=25,0,50,50&wid=50&hei=50&fit=stretch", + "https://dummy.scene7.com/is/image/DummyFolder/sample.jpg?crop=25,0,50,50&wid=50&hei=50&fit=stretch&qlt=85", ContentType.JPEG); } @@ -92,7 +92,7 @@ void testAsset_JPEG_AutoCrop() { void testAsset_JPEG_AutoCrop_ImageQuality() { Asset asset = createSampleAsset("/filetype/sample.jpg", ContentType.JPEG); buildAssertMedia_AutoCrop(asset, 50, 50, - "https://dummy.scene7.com/is/image/DummyFolder/sample.jpg?crop=25,0,50,50&wid=50&hei=50&fit=stretch", + "https://dummy.scene7.com/is/image/DummyFolder/sample.jpg?crop=25,0,50,50&wid=50&hei=50&fit=stretch&qlt=60", ContentType.JPEG, 0.6d); } @@ -102,7 +102,7 @@ void testAsset_JPEG_CropWithExplicitRendition() { Asset asset = createSampleAsset("/filetype/sample.jpg", ContentType.JPEG); context.create().assetRendition(asset, "square.jpg", 50, 50, ContentType.JPEG); buildAssertMedia_AutoCrop(asset, 50, 50, - "https://dummy.scene7.com/is/image/DummyFolder/sample.jpg?crop=25,0,50,50&wid=50&hei=50&fit=stretch", + "https://dummy.scene7.com/is/image/DummyFolder/sample.jpg?crop=25,0,50,50&wid=50&hei=50&fit=stretch&qlt=85", ContentType.JPEG); } @@ -148,7 +148,7 @@ void testAsset_GIF_Original() { void testAsset_GIF_Rescale() { Asset asset = createSampleAsset("/filetype/sample.gif", ContentType.GIF); buildAssertMedia_Rescale(asset, 80, 40, - "https://dummy.scene7.com/is/image/DummyFolder/sample.gif?wid=80&hei=40&fit=stretch", + "https://dummy.scene7.com/is/image/DummyFolder/sample.gif?wid=80&hei=40&fit=stretch&qlt=85", ContentType.JPEG); } @@ -157,7 +157,7 @@ void testAsset_GIF_Rescale() { void testAsset_GIF_AutoCrop() { Asset asset = createSampleAsset("/filetype/sample.gif", ContentType.GIF); buildAssertMedia_AutoCrop(asset, 50, 50, - "https://dummy.scene7.com/is/image/DummyFolder/sample.gif?crop=25,0,50,50&wid=50&hei=50&fit=stretch", + "https://dummy.scene7.com/is/image/DummyFolder/sample.gif?crop=25,0,50,50&wid=50&hei=50&fit=stretch&qlt=85", ContentType.JPEG); } @@ -235,7 +235,7 @@ void testFileUpload_PNG_AutoCrop() { void testAsset_TIFF_Original() { Asset asset = createSampleAsset("/filetype/sample.tif", ContentType.TIFF); buildAssertMedia(asset, 100, 50, - "https://dummy.scene7.com/is/image/DummyFolder/sample.tif?wid=100&hei=50&fit=stretch", + "https://dummy.scene7.com/is/image/DummyFolder/sample.tif?wid=100&hei=50&fit=stretch&qlt=85", ContentType.JPEG); } @@ -253,7 +253,7 @@ void testAsset_TIFF_Original_ContentDisposition() { void testAsset_TIFF_Rescale() { Asset asset = createSampleAsset("/filetype/sample.tif", ContentType.TIFF); buildAssertMedia_Rescale(asset, 80, 40, - "https://dummy.scene7.com/is/image/DummyFolder/sample.tif?wid=80&hei=40&fit=stretch", + "https://dummy.scene7.com/is/image/DummyFolder/sample.tif?wid=80&hei=40&fit=stretch&qlt=85", ContentType.JPEG); } @@ -262,7 +262,7 @@ void testAsset_TIFF_Rescale() { void testAsset_TIFF_AutoCrop() { Asset asset = createSampleAsset("/filetype/sample.tif", ContentType.TIFF); buildAssertMedia_AutoCrop(asset, 50, 50, - "https://dummy.scene7.com/is/image/DummyFolder/sample.tif?crop=25,0,50,50&wid=50&hei=50&fit=stretch", + "https://dummy.scene7.com/is/image/DummyFolder/sample.tif?crop=25,0,50,50&wid=50&hei=50&fit=stretch&qlt=85", ContentType.JPEG); } diff --git a/src/test/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaPathTest.java b/src/test/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaPathTest.java index ddd8680a..7d874ee2 100644 --- a/src/test/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaPathTest.java +++ b/src/test/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaPathTest.java @@ -33,6 +33,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.osgi.framework.Constants; import com.day.cq.dam.api.Asset; import com.day.cq.dam.api.DamConstants; @@ -82,6 +83,19 @@ void setUp() { @Test void testWidthHeight() { + String result = DynamicMediaPath.buildImage(damContext, 30, 25); + assertEquals("/is/image/DummyFolder/test?wid=30&hei=25&fit=stretch&qlt=85", result); + } + + @Test + void testWidthHeight_DisableSetImageQuality() { + // disable setImageQuality option + dynamicMediaSupportService = context.registerInjectActivateService(DynamicMediaSupportServiceImpl.class, + "setImageQuality", false, + Constants.SERVICE_RANKING, 1000); + damContext = new DamContext(asset, new MediaArgs(), mediaHandlerConfig, + dynamicMediaSupportService, webOptimizedImageDeliveryService, context.request()); + String result = DynamicMediaPath.buildImage(damContext, 30, 25); assertEquals("/is/image/DummyFolder/test?wid=30&hei=25&fit=stretch", result); } @@ -89,7 +103,7 @@ void testWidthHeight() { @Test void testWidthHeight_ImplicitSmartCrop() { String result = DynamicMediaPath.buildImage(damContext, 30, 20); - assertEquals("/is/image/DummyFolder/test%3ACrop-1?wid=30&hei=20&fit=stretch", result); + assertEquals("/is/image/DummyFolder/test%3ACrop-1?wid=30&hei=20&fit=stretch&qlt=85", result); } @Test @@ -106,49 +120,49 @@ void testWidthHeight_ImplicitSmartCrop_CroppingAreaTooSmall() { @Test void testCrop() { String result = DynamicMediaPath.buildImage(damContext, 30, 20, new CropDimension(5, 2, 10, 8), null); - assertEquals("/is/image/DummyFolder/test?crop=5,2,10,8&wid=30&hei=20&fit=stretch", result); + assertEquals("/is/image/DummyFolder/test?crop=5,2,10,8&wid=30&hei=20&fit=stretch&qlt=85", result); } @Test void testAutoCrop_SmartCrop() { String result = DynamicMediaPath.buildImage(damContext, 30, 20, new CropDimension(5, 2, 10, 8, true), null); - assertEquals("/is/image/DummyFolder/test%3ACrop-1?wid=30&hei=20&fit=stretch", result); + assertEquals("/is/image/DummyFolder/test%3ACrop-1?wid=30&hei=20&fit=stretch&qlt=85", result); } @Test void testWidthHeight_MaxWidth() { String result = DynamicMediaPath.buildImage(damContext, 3000, 1500); - assertEquals("/is/image/DummyFolder/test?wid=2000&hei=1000&fit=stretch", result); + assertEquals("/is/image/DummyFolder/test?wid=2000&hei=1000&fit=stretch&qlt=85", result); } @Test void testWidthHeight_MaxHeight() { String result = DynamicMediaPath.buildImage(damContext, 2500, 5000); - assertEquals("/is/image/DummyFolder/test?wid=1000&hei=2000&fit=stretch", result); + assertEquals("/is/image/DummyFolder/test?wid=1000&hei=2000&fit=stretch&qlt=85", result); } @Test void testWidthHeight_MaxWidthHeight() { String result = DynamicMediaPath.buildImage(damContext, 6000, 8000); - assertEquals("/is/image/DummyFolder/test?wid=1500&hei=2000&fit=stretch", result); + assertEquals("/is/image/DummyFolder/test?wid=1500&hei=2000&fit=stretch&qlt=85", result); } @Test void testRotate() { String result = DynamicMediaPath.buildImage(damContext, 30, 20, null, 180); - assertEquals("/is/image/DummyFolder/test?rotate=180&wid=30&hei=20&fit=stretch", result); + assertEquals("/is/image/DummyFolder/test?rotate=180&wid=30&hei=20&fit=stretch&qlt=85", result); } @Test void testCropRotate() { String result = DynamicMediaPath.buildImage(damContext, 30, 20, new CropDimension(5, 2, 10, 8), 90); - assertEquals("/is/image/DummyFolder/test?crop=5,2,10,8&rotate=90&wid=30&hei=20&fit=stretch", result); + assertEquals("/is/image/DummyFolder/test?crop=5,2,10,8&rotate=90&wid=30&hei=20&fit=stretch&qlt=85", result); } @Test void testAutoCropRotate_NoSmartCrop() { String result = DynamicMediaPath.buildImage(damContext, 30, 20, new CropDimension(5, 2, 10, 8, true), 90); - assertEquals("/is/image/DummyFolder/test?crop=5,2,10,8&rotate=90&wid=30&hei=20&fit=stretch", result); + assertEquals("/is/image/DummyFolder/test?crop=5,2,10,8&rotate=90&wid=30&hei=20&fit=stretch&qlt=85", result); } @Test