-
Notifications
You must be signed in to change notification settings - Fork 479
Description
Summary
WebP images are being processed/transformed during upload or when pushed to S3 storage, even when no transformation is requested. This results in visual quality degradation compared to the original uploaded image.
Affected Format
- WebP only - PNG and JPG images work correctly and maintain their original quality
- The same image exported to JPG/PNG before upload preserves quality correctly
Steps to Reproduce
- Upload a WebP image (especially a lossless WebP) to dotCMS
- Compare the original image with:
- The preview displayed inside dotCMS
- The image when pushed to AWS S3
Expected Behavior
The uploaded WebP image should be stored and served exactly as uploaded, without any re-encoding or transformation unless explicitly requested by the user.
Actual Behavior
The WebP image is being re-encoded, resulting in:
- Noticeable visual differences between the original and the processed image
- Different file sizes (in the reported case: original 64.57KB, AWS version 56.91KB)
- Loss of quality, especially noticeable with images that were originally lossless
Environment
- Reproduced on dotCMS demo environment
- Browser: Chrome 142.0.0.0
- OS: Mac OS 10.15.7
Technical Analysis
Looking at the codebase, the WebPImageFilter (dotCMS/src/main/java/com/dotmarketing/image/filter/WebPImageFilter.java) applies the following logic:
final int qualityParam = parameters.get(getPrefix() +"q") != null
? Integer.parseInt(parameters.get(getPrefix() +"q")[0])
: 85; // Default to 85% quality
Float quality = Float.valueOf(qualityParam);
quality = quality/100;
if(quality==1) {
writeParam.setCompressionType("Lossless");
} else {
writeParam.setCompressionType("Lossy");
writeParam.setCompressionQuality(quality);
}Key issue: Unless quality is explicitly set to 100%, the filter defaults to lossy compression at 85% quality. This means:
- Lossless WebP images get converted to lossy
- Already-lossy WebP images get re-compressed, potentially introducing additional artifacts
Suggested Fix
WebP images should be stored as-is during upload without any automatic re-encoding. Processing should only occur when:
- Explicitly requested through image filter parameters
- Generating thumbnails or resized versions for display
Related Code Files
dotCMS/src/main/java/com/dotmarketing/image/filter/WebPImageFilter.javadotCMS/src/main/java/com/dotmarketing/image/filter/ImageFilterApiImpl.javadotCMS/src/main/java/com/dotmarketing/servlets/BinaryExporterServlet.java(quality_q parameter handling)dotCMS/src/main/java/com/dotmarketing/servlets/ShortyServlet.java(image URL processing)
Support Ticket Reference
Reported via support ticket - Customer confirmed issue with WebP images uploaded to their environment.
https://helpdesk.dotcms.com/a/tickets/34265
Additional Context
- Other formats (JPG, PNG) are not affected
- The issue specifically impacts WebP format handling
Metadata
Metadata
Assignees
Labels
Type
Projects
Status