Skip to content

Allow cloning of GdImage from gd 2.2.3#10241

Closed
blar wants to merge 6 commits into
php:masterfrom
blar:gdimage-clone
Closed

Allow cloning of GdImage from gd 2.2.3#10241
blar wants to merge 6 commits into
php:masterfrom
blar:gdimage-clone

Conversation

@blar

@blar blar commented Jan 6, 2023

Copy link
Copy Markdown
Contributor

From version 2.2.3 gd supports cloning https://libgd.github.io/manuals/2.2.3/files/gd-c.html#gdImageClone

The bundled version of gd is at version 2.0.35 so cloning is only supported with --with-external-gd

@iluuu1994 iluuu1994 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.

LGTM, but maybe @cmb69 wants to have a look?

Comment thread ext/gd/tests/gdimage_cloning.phpt Outdated

@cmb69 cmb69 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.

Thank you for the PR!

I fully agree that it makes sense to expose gdImageClone() to userland, but not 100% sure about whether via clone or a new function (imageclone()). Since we're having objects now, the former probably makes most sense.

Regarding the libgd version requirements: there are several known bugs in that function, and some have not even been fixed yet (albeit quite serious). Maybe we should require a newer version right away? On the other hand, bugs in external libraries are not uncommon, so we can stick with libgd ≥ 2.2.

The bundled version of gd is at version 2.0.35 so cloning is only supported with --with-external-gd

ext/gd is lying. :) There have been several updates (bugfixes and features), but the bundled gd never conformed to any particular libgd version. We might update these version numbers, although the long term goal is still to unbundle libgd (what is still blocked by libgd/libgd#335).

Anyhow, we could port gdImageClone() from libgd right away, so more users could use the new feature. This could alternatively be done via a separate follow-up PR.

Comment thread ext/gd/tests/gdimage_cloning.phpt Outdated
Comment thread ext/gd/tests/gdimage_cloning.phpt
Comment thread ext/gd/tests/gdimage_cloning.phpt Outdated
Comment thread ext/gd/tests/gdimage_prevent_cloning.phpt Outdated
@blar

blar commented Jan 6, 2023

Copy link
Copy Markdown
Contributor Author

I fully agree that it makes sense to expose gdImageClone() to userland, but not 100% sure about whether via clone or a new function (imageclone()). Since we're having objects now, the former probably makes most sense.

The function imageclone() only make sense if you want to backport it to a version of php before 8.0.0, which don't had the GdImage class. Additionally developers may question why every other (clonable) class can be cloned with clone, but GdImage requires imageclone().

@cmb69

cmb69 commented Jan 6, 2023

Copy link
Copy Markdown
Member

Additionally developers may question why every other (clonable) class can be cloned with clone, but GdImage requires imageclone().

I agree (although devs also may wonder why there are no methods for this class). :)

@TimWolla

TimWolla commented Jan 6, 2023

Copy link
Copy Markdown
Member

With #10225, I agree that the clone operator is the right choice.

Comment thread ext/gd/gd.c Outdated
@blar blar requested a review from cmb69 February 6, 2023 16:48
@ndossche ndossche requested a review from devnexen as a code owner March 14, 2026 14:04
@pierrejoye

Copy link
Copy Markdown
Contributor

see #22532

@pierrejoye pierrejoye closed this Jul 8, 2026
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.

7 participants