Run function before uploaded image is saved

I wish to run the following ImageMagick command before each image is saved to the server, how can I do so:

convert image_name.jpg -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace RGB image_name.jpg

Topic compression images Wordpress

Category Web


WordPress already compresses jpeg files, doing it a second time will just degrade the quality with recompression artefacts

Instead, adjust the compression percentage via the jpeg_quality filter:

add_filter( 'jpeg_quality', function() {
    return 80; // 80%
});

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.