Skip to content

ext/gd: imageclone support. #14487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

ext/gd: imageclone support. #14487

wants to merge 2 commits into from

Conversation

devnexen
Copy link
Member

@devnexen devnexen commented Jun 5, 2024

No description provided.

@devnexen devnexen marked this pull request as ready for review June 6, 2024 19:56
@devnexen devnexen requested a review from kocsismate as a code owner June 6, 2024 19:56
@thg2k
Copy link
Contributor

thg2k commented Jun 10, 2024

I believe it would cause a memory leak if the cloned image has a tile or a brush. And likely an infinite recursion if the tile has the cloned image as its tile.. but that's something that should be addressed by libgd.

@thg2k
Copy link
Contributor

thg2k commented Jun 14, 2024

Also, this overlaps with #10241. Personally I like the explicit imageclone better than the clone $im approach, especially because it's nicer to feature check with function_exists("imageclone") rather than try { clone $im } catch (Error ...).

@kocsismate
Copy link
Member

LGTM but I'm not familiar with ext/gd... It would be nice to find someone who is familiar with it.

@cmb69
Copy link
Member

cmb69 commented Aug 29, 2024

It would be nice to find someone who is familiar with it.

Given that @devnexen is code owner of ext/gd and also maintainer of libgd, I would think this is not an issue. :)

Generally, I agree that we should support gdImageClone(), but I'm still not quite sure whether as function or via the clone operator. @thg2k has a good point regarding feature detection, though.

But regardless whether we take this approach or the one from #10241, we should port gdImageClone() into our bunded libgd.

@thg2k
Copy link
Contributor

thg2k commented Aug 31, 2024

Apparently gdImageClone made it to the bundled libgd in #15640.

Now, what about the userland method? Why can't we have both imageclone and clone $im support?

Also I would still unset brushes and tiles from the cloned image to avoid memory leaks. But there are other issues with those anyway.

@devnexen
Copy link
Member Author

Apparently gdImageClone made it to the bundled libgd in #15640.

Now, what about the userland method? Why can't we have both imageclone and clone $im support?

having both makes sense for me

@cmb69
Copy link
Member

cmb69 commented Aug 31, 2024

Now, what about the userland method? Why can't we have both imageclone and clone $im support?

What about having GdImage::clone() as well? ;)

Also I would still unset brushes and tiles from the cloned image to avoid memory leaks. But there are other issues with those anyway.

That should be reported to upstream, and fixed there first. In my opinion, fixing our bundled libgd should be a last resort.

@thg2k
Copy link
Contributor

thg2k commented Aug 31, 2024

Now, what about the userland method? Why can't we have both imageclone and clone $im support?

What about having GdImage::clone() as well? ;)

I can sense the sarcasm, but yes why not adding all image functions as methods of the gd object? Similar to the mysqli approach. But that's off topic here. If this happens, i'd really like to see the imageclone function for consistency. Mixing oop and functional approach is just ugly.

How about we go with the function now and then we do a separate pr where we alias all the functions and add the clone as well?

Also I would still unset brushes and tiles from the cloned image to avoid memory leaks. But there are other issues with those anyway.

That should be reported to upstream, and fixed there first. In my opinion, fixing our bundled libgd should be a last resort.

I would, and also report other minor problems I found, but the project looks dead in the water.

@cmb69
Copy link
Member

cmb69 commented Aug 31, 2024

[…], but yes why not adding all image functions as methods of the gd object?

That is actually the long-term goal; changing resources to opaque objects was/is just a stop-gap measure to get of resources as soon as possilbe.

I would, and also report other minor problems I found, but the project looks dead in the water.

I know at least two libgd maintainers who are actively working on php-src; these might find some time to at least provide fixes against libgd (ideally just merging a PR).

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.

4 participants