[wp-trac] [WordPress Trac] #61597: Resized images larger in filesize than original, when setting jpeg_quality to 100

WordPress Trac noreply at wordpress.org
Mon Jul 8 19:41:46 UTC 2024


#61597: Resized images larger in filesize than original, when setting jpeg_quality
to 100
--------------------------+-----------------------------
 Reporter:  johnny538     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  6.5.5
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I prefer to optimize my images before I upload them. One of the reasons is
 so I can avoid image optimization plugins.

 I set the jpeg compression quality to 100 using the `jpeg_quality` filter.
 This works like intended. My original image remains the same file size.

 But when WordPress resizes images according to all the registered sizes,
 they're often much larger than the original, even though the image
 dimensions are now smaller.

 For example, when uploading a 640x427 jpeg at 11kb, the resized 300x200
 version is now 30kb. Almost triple the size of the original file, which is
 larger in dimensions. Even the thumbnail version of 150x150 is 14kb.

 Just imagine how this would go on a large site with gigabytes worth of
 images...

 **Steps to reproduce:**

 1. Add the snippet to disable compression:
 {{{#!php
 <?php
 add_filter('jpeg_quality', 'reset_jpeg_quality');
 function reset_jpeg_quality($args) {
     return 100;
 };
 }}}


 2. Upload a jpeg image
 3. View the generated sizes in your media directory (using ftp or a file
 manager)

 **What I expect to see instead?**

 The resized versions, if smaller in dimensions, should also be smaller in
 file size. Or generation should be skipped entirely if the file size is
 larger.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61597>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list