Stop WordPress Image Compression
-
Is there a way to get WP to just resize an image but not apply any optimisation?
As we know WordPress applies a default image compression on all images uploaded to create the different sizes as set for your WP image sizes, e.g. 1200, 600 and 300. From what I am reading that is 82%.
I use TinyJPG to optimise my files (manually not a WP plugin) before I add them to WP, and hence the optimisation is done and no further optimisation is required.
Since I do not want to have any further image compression done by WP I placed this in my functions file.
add_filter( 'jpeg_quality', 'my_custom_jpeg_quality' ); function my_custom_jpeg_quality( $quality ) { return 100; }
From what I could tell at the time adding this, it overrides the default WP 82% image compression and uses 100%, which I assumed was to not apply any further compression?
However when I do this the created images sizes, 1200, 600 and so on are bigger than the size of the original, they are the required dimensions but the file sizes are much bigger.
For example I have a photo 1400 x 1100 pixels, I then optimise that using TinyJPG (manually not a plugin). The optimised file goes from the original 1.1MB to 165KB, still at the same 1400 x 1100 pixels. Awesome :).
I then upload that file to my WP site (WooCommerce Product). It then goes and creates the set image sizes, e.g. 1200, 900 and 300.
The problem I have is that the created WP images are resized but they are larger file sizes than the original, and by a big margin. e.g the 1200 is 689KB, 900 is 443KB … This is after I have already optimised the image via TinyJPG.
Why does it do this and how can I get it to resize based on the original file compression, as in be smaller in size than the original file which would make more sense.
Thanks for your help
- The topic ‘Stop WordPress Image Compression’ is closed to new replies.