Skip to content
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

imagescale(): Argument #3 ($height) must be between 1 and 2147483647 #17703

Open
valeriiabykovets opened this issue Feb 5, 2025 · 7 comments

Comments

@valeriiabykovets
Copy link

imagescale(): Argument php/doc-en#3 ($height) must be between 1 and 2147483647. -1 is no longer allowed?

From manual page: https://php.net/function.imagescale


@devnexen
Copy link
Member

devnexen commented Feb 5, 2025

That looks like a php issue. transferring.

@devnexen devnexen transferred this issue from php/doc-en Feb 5, 2025
@devnexen devnexen self-assigned this Feb 5, 2025
@devnexen
Copy link
Member

devnexen commented Feb 5, 2025

@valeriiabykovets would you mind sharing your use case to be able to reproduce ?

@nielsdos
Copy link
Member

nielsdos commented Feb 5, 2025

Probably a negative value flipped the image? Just a guess

@devnexen
Copy link
Member

devnexen commented Feb 5, 2025

So gdImageSx might need to return 0 in this case with height set to -1.

@nielsdos
Copy link
Member

nielsdos commented Feb 5, 2025

Also I think that -2 flips and makes the height twice as much. So any value except 0 should probably be allowed.
Edit: ah not really, this isn't a factor, but a negative value preserves the aspect ratio. According to the manual -1 is even the default.

@valeriiabykovets
Copy link
Author

I found that this error happened because of scaling the file 400x1. While previously the method returned false in such cases, since php 8.4.0 it throws error.
Thank you for your feedbacks)

@cmb69
Copy link
Member

cmb69 commented Feb 5, 2025

if (tmp_h < 0 || tmp_w < 0) {

If both width and height are negative, we should probably throw a ValueError with a suitable message. Not sure if the current behavior qualifies as bug, though (imagescale($im, -1, -1) already throws Argument #2 ($width) must be between 1 and 2147483647, what is not completely wrong).

devnexen added a commit to devnexen/php-src that referenced this issue Feb 5, 2025
…lues.

Throwing a ValueError in this particular case.
devnexen added a commit to devnexen/php-src that referenced this issue Feb 5, 2025
…lues.

Throwing a ValueError in this particular case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants