If you want to showcase high-quality images on your website, then you can turn off image compression in WordPress.
You can do that by adding this part of code in your functions.php
:
add_filter('jpeg_quality', function($arg){return 100;});
Or you can create your plugin :
<?php
/**
* Plugin Name: Remove WordPress Image Compression
* Plugin URI: [Plugun URI}
* Version: 1.0
* Author: [Your name]
* Author URI: [Your URI]
* Description: This will remove the compression WordPress, applies to images when uploading to your media library.
*/
/**
* Override the default image quality when resizing and cropping images
*/
add_filter('jpeg_quality', function($arg){return 100;});
The code above sets the value to 100. It means that WordPress compresses the image at its highest quality.
Now, after activating the plugin, any new image uploaded will no longer be subject to WordPress image compression. Keep in mind that was previously uploaded to activating your plugin will need to be re-uploaded to have the compression removed.