Review main Merged

94297[BUGFIX] Convert float precision in image crop command

Stig Nørgaard Færch CR +2 V +2 Normal +128 −1 updated 06/10/26, 01:54

Commit message

`Area::applyRatioRestriction()` can produce near-zero
float residuals (e.g. 1.14e-13) for crop offsets.
PHP 8.4 renders these in scientific notation when
cast to string, causing ImageMagick to reject the
`-crop ...` parameter geometry.

This patch fixes the issue by casting values to
integers via round() - since pixel dimensions are
passed to ImageMagick, floats would never be utilized.

A test to cover this scenario is added.

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Oliver Klee +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Oliver Klee +1
    • core-ci +1 CI

Issues 1

Files 4

Review log 1217

  1. Stig Nørgaard Færch uploaded patch set 1 06/03/26, 11:45

  2. core-ci voted on patch set 1 V +1 06/03/26, 11:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102889

  3. Garvin Hicking updated the commit message in patch set 2 V +1 06/03/26, 14:13

  4. core-ci voted on patch set 2 V +1 06/03/26, 14:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102908

  5. Stig Nørgaard Færch updated the commit message in patch set 3 V +1 06/03/26, 14:23

  6. Garvin Hicking updated the commit message in patch set 4 06/03/26, 14:28

  7. core-ci voted on patch set 3 V +1 06/03/26, 14:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102910

  8. core-ci voted on patch set 4 V +1 06/03/26, 14:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102911

  9. Garvin Hicking commented on patch set 4 06/03/26, 14:38

    Thanks for contributing this as mentioned on Slack 😊 I think we should take this opportunity to create a test method, because currently there is no single functional test covering our `GraphicalFunctions` sadly. So we should have a test there that creates a thumbnail from crop values (and without) and also with floating values and those without. I wonder about your "1.14e-13" example, which would result in "0.00...0014" which would then be rounded to "0". Shouldn't it be "1" instead, otherwise the crop would yield a 0px image?
  10. Garvin Hicking uploaded patch set 5 V +1 06/04/26, 19:00

  11. core-ci voted on patch set 5 V +1 06/04/26, 19:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102981

  12. Garvin Hicking commented on patch set 5 CR +1 V +1 06/04/26, 19:16

    Reply

    I've added a test now and it seems this all works out.
  13. Garvin Hicking commented on patch set 5 06/04/26, 19:17

    Reply

    Done
  14. Oliver Klee voted on patch set 5 V +1 06/04/26, 19:37

  15. Oliver Klee voted on patch set 5 CR +1 06/04/26, 19:37

  16. Garvin Hicking voted on patch set 5 CR +2 V +2 06/10/26, 01:53

  17. Garvin Hicking merged patch set 6 06/10/26, 01:54