JPG Quality and WordPress

The EWWW IO plugin for WordPress allows you to change the default JPEG/JPG quality used by WordPress, but before you do, it's good to know a little more about what you can expect. There are also some common misconceptions that I see online about JPEG quality, so here goes:

JPEG Quality is Not a Percentage

The first misconception many have about JPEG quality is that it is a percentage. It is nothing of the sort. Rather, it is a quality slider, and the values don’t even have to be 1-100. If you’ve used Photoshop, it even uses two different scales: one is 1-12, and the other is the typical 1-100 range that is used by WordPress (via GD, Imagick, or GMagick) and most other JPG compressors. Every tool is free to interpret the quality levels however they want, and the nature of JPEG compression means that different software often uses different algorithms during compression. This also means that it is impossible to know what quality level was used on a JPEG image unless you know what software created it, and even then it is just an educated guess (some guesses are better than others). 

The typical quality scale is also not linear, it’s more exponential (although technically I think it might be logarithmic). This means that the higher you go, the less quality improvement there is, but the file size increases dramatically for each increase in quality. Conversely, the lower you go, the faster the quality degrades, and the file size drops less for each step. Typically, a quality between 70 and 90 is preferable to most people, and the value of 82 that WordPress now uses is well within the accepted bounds of quality loss. This is based on a study published by Radware in 2014 where they determined how much you could alter an image that would still be considered acceptable by users/visitors.

Quality 100 is Not Lossless

A second problem some folks run into, is that they think setting it to quality 100, or 12 in Photoshop, will disable compression altogether. That just isn’t true, since JPEG is by definition a lossy format. Every single time you re-export or re-save a JPEG file, you will lose pixels, even at maximum quality. The only way to reduce file size, and achieve zero pixel loss, is the lossless compression employed by tools like jpegtran or jhead. Since they don’t alter the image itself, the back-end encoding is all that changes. It’s similar in nature to how lossless PNG compression works. The pixels are all preserved, the tools just look for optimal compression parameters, which takes more time and resources. Camera manufacturers (and most photo editors) default to a level of compression that trades size for speed. They figure people want their images to save faster, rather than achieving maximum compression. In the case of cameras, battery usage is also a concern, since the extra compression would put a higher strain on the processor, and drain the battery much faster. And I think the camera folks probably have it right, people don’t like to wait for their camera to save an image, they want to get on with taking more pictures, especially since storage is so cheap.

Quality vs. File Size

WordPress Does Not Modify Uploaded Images

The last misconception is that WordPress decreases the quality of images you upload. Prior to version 5.3, WordPress does NOT modify your uploaded images by default. It just transfers them straight to the server, unaltered, and uses that unaltered original to create the resized versions (thumbnails). The resizes are where the quality loss is introduced, and this is where the quality level of 82 comes into play. There is a way that your originals CAN be changed though. If you are using WordPress 5.3+ it resizes your original to 2560px wide, but saves the original separately for use in generating the resizes. Also, if you use a plugin to resize the uploads with a maximum resolution, then the plugin that does the resizing will be using the default quality of 82, or whatever you have configured. EWWW IO and Imsanity are two such plugins that can be configured to resize your original uploads.

Still need help? Contact Us Contact Us