Skip to content

Sync gd 2 4 - #22532

Merged
pierrejoye merged 70 commits into
php:masterfrom
pierrejoye:SYNC_GD_2_4
Jul 16, 2026
Merged

Sync gd 2 4#22532
pierrejoye merged 70 commits into
php:masterfrom
pierrejoye:SYNC_GD_2_4

Conversation

@pierrejoye

@pierrejoye pierrejoye commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Sync php's libgd to current GD's master, which will be 2.4.0

New APIs

Updated/Fixed

  • Color Match improvement using Lab* + Delta-E and actual % as input
  • Fix and improve freetype rendering and merge both php's libgd + libgd "new encoding"
    . Fix RAMQ rendering
  • All codecs with conformance tests (upstream, C)
  • Perceptual difference (upstream C, will be exposed so php's tests can rely on it

WIP:

This is the 1st phase, to ensure it builds correctly in php's CI. And hopefully the new deps will be added as well.

The next phases is to expose the new APIs in php's.

@edorian

edorian commented Jul 7, 2026

Copy link
Copy Markdown
Member

Great. All public feedback processed. Let me know if there is anything I can help with still @bukka. You're also on /cc for the other discussion.

So 👍 from my side so far

@TimWolla TimWolla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please refrain yourself to slip in changes not related to the topic at hand. Adding you as code owner could be done in a separate PR.

@pierrejoye I agree with David here. Can you commit the CODEOWNER change (and any other change that is not purely related to the GD sync) separately, please?

@pierrejoye

Copy link
Copy Markdown
Contributor Author

please refrain yourself to slip in changes not related to the topic at hand. Adding you as code owner could be done in a separate PR.

@pierrejoye I agree with David here. Can you commit the CODEOWNER change (and any other change that is not purely related to the GD sync) separately, please?

reverted.

@TimWolla
TimWolla dismissed their stale review July 9, 2026 10:34

Resolved

@TimWolla

TimWolla commented Jul 9, 2026

Copy link
Copy Markdown
Member

Thanks.

As for the sync itself: Is it possible to automate the sync with a script similar to https://github.com/php/php-src/blob/master/ext/lexbor/patches/update-lexbor.sh?

This would make verification and future synchronization much easier. The sync should then also happen in a single commit, since individual commits for individual components will result in an inconsistent state for intermediate commits.

Comment thread ext/gd/gd.c
Comment on lines +302 to +309
/* Keep PHP's historical PNG warning text while bundled gd_png.c stays
* identical to upstream libgd. */
if (strcmp(format, "gd-png: fatal libpng error: %s\n") == 0) {
format = "gd-png: fatal libpng error: %s";
} else if (strncmp(format, "gd-png error: setjmp returns error condition",
sizeof("gd-png error: setjmp returns error condition") - 1) == 0) {
format = "gd-png error: setjmp returns error condition";
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this logic is necessary, there is explicitly no BC guarantee for error messages in PHP.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but some phpt rely on those. So I keep them the same so tests don't need updates.

@pierrejoye

pierrejoye commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Thanks.

As for the sync itself: Is it possible to automate the sync with a script similar to https://github.com/php/php-src/blob/master/ext/lexbor/patches/update-lexbor.sh?

This would make verification and future synchronization much easier. The sync should then also happen in a single commit, since individual commits for individual components will result in an inconsistent state for intermediate commits.

Not totally yet. There are a few things I like to change in ext/gd/libgd first to make it possible. The target is to do not need any script at all. Anything that needs to be specific to php will be separate files.

The issue now is that we include php's config and other similar headers as well in ext/gd/libgd/, for the php's versions of various libc functions etc. That makes automatic sync more tricky, especially for the APIs transferring memory ownership f.e., or having slighly different signatures. Some uses different types as well, making build not warning free or may affect behaviors in some edge cases.

But now, to achieve this will be significantly easier. Adding specific defines, or thin wrappers for those, upstream using the standard libc and php's use php's ones. But that is not the scope of this PR. This PR is soleny about having 2.4 synced here, tests and audits green.

I (desperately) wait for this PR to be approved, while it is approved by the last reviewer on internals, by Ilia, and indeed myself lol ;-)

The actual PR for 2.4 additions in PHP is what matters here, see https://wiki.php.net/rfc/ext-gd-2.4. Still drafting it, but it already gives a good idea.

@pierrejoye

Copy link
Copy Markdown
Contributor Author

just a head up :)

@bukka possible to approve here too? approved on internals but it does make it approved here (I try to stick to the process). All issues reported here or by Volker solved but the sec, or sec-like, ones which will be done using the normal fix only and merge to active branches separately in coordination with the respective RMs.

Alternatively I can merge tomorrow, so I can push the actual 8.6 addition PR then. is that ok? :)

@pierrejoye

pierrejoye commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

ok, missed alpha2..... We have an issue with PRs handling, and security+RMs. I will check out what could work better and propose something to internals

@pierrejoye
pierrejoye merged commit d826d49 into php:master Jul 16, 2026
18 checks passed
@Girgias

Girgias commented Jul 17, 2026

Copy link
Copy Markdown
Member

This is breaking the Solaris build:

  /home/runner/work/php-src/php-src/ext/gd/libgd/gdkanji.c:22:15: error: conflicting types for ‘iconv_t’; have ‘void *’
     22 | typedef void *iconv_t;
        |               ^~~~~~~
  In file included from /home/runner/work/php-src/php-src/ext/gd/libgd/gdkanji.c:15:
  /usr/include/iconv.h:73:29: note: previous declaration of ‘iconv_t’ with type ‘iconv_t’ {aka ‘struct _iconv_info *’}
     73 | typedef struct _iconv_info *iconv_t;
        |                             ^~~~~~~

@bukka

bukka commented Jul 19, 2026

Copy link
Copy Markdown
Member

@devnexen could you please look into that Solaris issue. It's preventing us to verify the stream changes so it would be great to have it working soon.

@Jan-E

Jan-E commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

This seems to break VS18 builds (PHP 8.6.0 Alpha 3. x64, both NTS and ZTS) on Windows:

ext\gd\libgd\gd_avif.c(591): error C2440: '=': cannot convert from 'void' to 'avifResult'
ext\gd\libgd\gd_avif.c(591): error C2186: '=': an operand cannot have type 'void'

result = avifRGBImageAllocatePixels(&rgb);

// this allocates memory, and sets rgb.rowBytes and rgb.pixels.
    result = avifRGBImageAllocatePixels(&rgb);

@Jan-E

Jan-E commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

My bad. I had to upgrade the dependency: libavif-1.4.2

@orlitzky

orlitzky commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Will there be a new libgd-2.4.x release before this hits a PHP release? Otherwise the tests that have been updated (e.g. https://github.com/php/php-src/blob/master/ext/gd/tests/bug73291.phpt) will fail with any available external libgd.

(In that example, a SKIPIF could probably fix it, but I'm not sure what the maintainers consider essential behavior of the gd extension.)

adrian-enspired pushed a commit to adrian-enspired/php-src that referenced this pull request Aug 4, 2026
1st part of syncing bundled LibGd to ext/gd/libgd
# Updated/Fixed

- Color Match improvement using Lab* + Delta-E and actual % as input
- Fix and improve freetype rendering and merge both php's libgd + libgd "new encoding"
 -  Fix RAMQ rendering
- All codecs with conformance tests (upstream, C)
- Perceptual difference (upstream C, will be exposed so php's tests can rely on it
- libgd codecs include gif, bmp, webp and jxl full support including animation. Tiff read/write multipages. all BMP format supported but OS/2.

Many of these additions or changes work already with existing php's apis.

2D vector APIs and all new Codecs or Gd\* APIs will be a separe PR+RFC. See https://wiki.php.net/rfc/ext-gd-2.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants