How to Increase or Decrease the Compression Quality of JPG Images

Compression Quality of JPG Images

Many webmasters, don’t pay much attention to the quality of JPG images. (quality of the pictures on their website) Although there are photographers who focus on images, and the JPG images uploaded by WordPress loses some information after an upload.

JPG images upload

Since we are not photographers, we may not care about the loss of picture quality. That is, by default, WordPress processing of JPG images retains 90% of the quality. The question now is how to achieve better quality? The following code is used.

<pre> add_filter ('jpeg_quality', function ($ arg) {return 100;}); </ pre>

Paste the above code into function.php, so that uploaded jpg files will maintain 100% quality. Notice a 100 in the code, this is to control the quality. If compression is not needed, set it to 100, To keep the quality a little lower, set it to <100, not too small, it is recommended to be between 80-100.

It depends on what the website focuses on. If it is a normal website, set it a little smaller. Design, image, and product websites should be better than 90. To retain more details.

Note: For some old versions of PHP, there may be errors when using the above code, this time use the following code:

function jpeg_quality_callback ($ arg)

{

return (int) 100;

}

 

add_filter ('jpeg_quality', 'jpeg_quality_callback');

You May Also Like

About the Author: BW

1 Comment

  1. Pingback: Introduction to Lossy and lossless image compression - BookWebmaster

Leave a Reply

Your email address will not be published. Required fields are marked *