Open badbadmonkey opened 6 years ago
Since you're more familiar with the issue than I, could you apply whatever modifications you think appropriate and submit a pull request.
My hack above just implements what I think appropriate for my particular site. I wouldn't advocate it for all. I'm just throwing the idea here to try to put it on your radar as it's become more of an optimization issue lately.
What I would suggest is firstly adding core support with sensible defaults, but also surfacing control in the config or defaults, and adding an URL parameter at least just accessing -sampling-factor, to allow smart usage when it comes to using srcset and
If you would like to have it in phpThumb, I leave it to you (or someone) to suggest and submit an implementation. I'm essentially unfamiliar with the issue.
Just a suggestion - at present phpThumb provides no control over chroma subsampling of JPEGs produced, relying on the defaults for sampling-factor with ImageMagick. I wonder if such control might be surfaced along with defaults.
For example I currently hack phpThumb.class.php as follows just above the final lines generating $commandline ~
Which hard-codes my own preferences but obviously options would be better. I think it's particularly useful nowadays with us having to deal with both low and high dpi client screens.
The other logic that would be useful to build in would be graceful degradation of the setting so that a higher subsampling wasn't used than the source JPG justified. This is where phpThumb has a role to play beyond the defaults from ImageMagick.
For example if a 1000px 4:2:0 JPG is resized to 500px, the thumbnail could be subsampled at 4:4:4 if the user settings desired it, but not if it's resized to say 800px. On the other hand a 4:4:4 source would justify the same at any downsize resolution.