Search code examples
phpwordpresswordpress-hook

Is there a way to use progressive JPEG with WordPress?


I am trying to use progressive JPEG but it looks like WordPress does not respect chosen type that is used for displaying image's content.

I convert JPEG image with this command:

convert bunny.jpg -interlace plane progressive-bunny.jpg

After upload, image displays as a baseline JPEG.

I am aware of that WordPress does some post-processing after upload and probably that is the main reason why images end up as a baseline JPEG but I wonder if there is a way to turn this feature off or make it respects original type?

I tried to disable optimization by adding these two lines to functions.php but it does not work, it only increases the size of uploaded files.

add_filter('jpeg_quality', function($arg) {return 100;});
add_filter('wp_editor_set_quality', function($arg) {return 100;});

Solution

  • I think some plugins can handle progressive jpeg for their images optimizations options:

    When you upload an image on WordPress:

    • it'll create multiple different sizes of the images: large, small, thumbnail... and any other you could have defined
    • it'll also store the original file, but I don't know if any image manipulation is done to the file beside the filename.
    • Did you check if the original file is still progressive jpeg? or also converted somehow.

    If WordPress media system doesn't support progressive jpeg, optimizer plugins will mostly hook after (or replace) the WordPress media method to make their own image manipulation. But it may be a lot of custom code, so a plugin may be worth it (IF you're sure that WordPress doesn't support natively progressive jpeg, and that it converts your progressive jpeg to standard one).