Skip to content

Commit

Permalink
introduce getDefaultImageQualityPercentage
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Jan 17, 2024
1 parent fb55a77 commit f57c866
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/io/wcm/handler/media/spi/MediaHandlerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public abstract class MediaHandlerConfig implements ContextAwareService {
}

/**
* Get the default quality for images in this app generated with the Layer API.
* Get the default quality for images.
* The meaning of the quality parameter for the different image formats is described in
* {@link com.day.image.Layer#write(String, double, java.io.OutputStream)}.
* @param contentType MIME-type of the output format
Expand All @@ -106,7 +106,7 @@ public abstract class MediaHandlerConfig implements ContextAwareService {
public double getDefaultImageQuality(@Nullable String contentType) {
MediaFileType mediaFileType = MediaFileType.getByContentType(contentType);
if (mediaFileType != null && mediaFileType.isImageQualityPercentage()) {
return DEFAULT_IMAGE_QUALITY;
return getDefaultImageQualityPercentage();
}
else if (mediaFileType == MediaFileType.GIF) {
return 256d; // 256 colors
Expand All @@ -115,6 +115,15 @@ else if (mediaFileType == MediaFileType.GIF) {
return 1d;
}

/**
* Get the default quality for images.
* This parameter only applies to images with lossy compression (e.g. JPEG).
* @return Quality percentage (0..1)
*/
public double getDefaultImageQualityPercentage() {
return DEFAULT_IMAGE_QUALITY;
}

/**
* With this switch it's possible to switch all used property and node names from (legacy) wcm.io
* Handler standard to Adobe Standard (as used e.g. in Adobe Core WCM Components) - e.g.
Expand Down

0 comments on commit f57c866

Please sign in to comment.