Skip to content

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

Closed

Description

@valeriiabykovets

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


Activity

  1. devnexen commented on Feb 5, 2025

    @devnexen
    Member

    That looks like a php issue. transferring.

  2. transferred this issue fromphp/doc-enon Feb 5, 2025
  3. self-assigned this
    on Feb 5, 2025
  4. devnexen commented on Feb 5, 2025

    @devnexen
    Member

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

  5. ndossche commented on Feb 5, 2025

    @ndossche
    Member

    Probably a negative value flipped the image? Just a guess

  6. devnexen commented on Feb 5, 2025

    @devnexen
    Member

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

  7. ndossche commented on Feb 5, 2025

    @ndossche
    Member

    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.

  8. valeriiabykovets commented on Feb 5, 2025

    @valeriiabykovets
    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)

  9. reopened this on Feb 5, 2025
  10. added theissue type on Feb 5, 2025
  11. cmb69 commented on Feb 5, 2025

    @cmb69
    Member

    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).

  12. removed theissue type on Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions