GD image toolkit does not correctly handle gamma when resizing images.

Created on 13 March 2012, almost 13 years ago
Updated 22 September 2023, over 1 year ago

Problem/Motivation

The GD toolkit does not correctly handle gamma when resizing images, because of a limitation of the GD library.

Proposed resolution

As explained here:
http://www.4p8.com/eric.brasseur/gamma.html
A workaround is to alter image gamma to achieve a linear scale before resizing, and change it back to original after having resized.

The patch is quite simple, it just calls imagegammacorrect before and after imagecopyresampled.

Result comparison

Using this original image for example:

This is what Drupal currently gives after resizing and cropping to 75x75px:

and after patching:

The second scaled image is visually closer to the unscaled image.

Steps to reproduce

  1. Use the image in the Issue Summary
  2. Make a image style, resize 75x75px
  3. Change the article content type to use the new image style
  4. Upload the image in the issue summary

Proposed resolution

Remaining tasks

Update the patch
Add a test
Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Image system 

Last updated 1 day ago

Created by

🇫🇷France SeeSchloss

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024