# How to change JPEG compression rate in WordPress

> If you need pixel-perfect photos in WordPress, you need to change the JPEG compression rate or simply disable it. You can do it via a simple filter.

- URL: https://graffino.com/til/how-to-change-jpeg-compression-rate-in-wordpress
- Author: Zeno Popovici
- Channel: wordpress
- Published: 2020-04-10
- Updated: 2022-03-31

Our client wants pixel perfect images in his WordPress site. Truth is WordPress is a bit agressive in compressing JPEGs.

WordPress default is 75% compression quality. A higher setting will generate better looking images, to the expense of larger filesize.

Add this to your `functions.php` file:

```
// Change JPEG compression rate - 85 is much more reasonable setting
// You can also disable it by settign it to 100
$jpeg_compression = function() { 
	return 85; 
};

add_filter( 'jpeg_quality', $jpeg_compression );
```
