|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64862 imagecopyresized doesn't handle negative width/height
Submitted: 2013-05-16 18:18 UTC Modified: 2021-08-25 13:50 UTC
Avg. Score:3.0 ± 2.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: matteosistisette at gmail dot com Assigned: cmb (profile)
Status: Wont fix Package: GD related
PHP Version: 5.3.25 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-05-16 18:18 UTC] matteosistisette at gmail dot com
There's no reason why imagecopyresized shouldn't accept and properly handle a 
negative width and/or height as source or target dimentions.

It's perfectly natural to copy a rectanguar region of an image while applying it 
a negative scale so as to flip it. It's totally ridiculous that you have to copy, 
flip and then copy it again resized. Especially considering  that prior to 5.5 
imageflip doesn't even exist.

At the very least negative dimensions should be supported on either source or 
target, though the normal way would be to support both.

Test script:



Expected result:
image should be flipped vertically

Actual result:
An error is issued:
imagecopyresized(): Invalid image dimensions 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-20 20:05 UTC]
-Type: Bug +Type: Feature/Change Request
 [2017-01-23 13:51 UTC]
-Status: Open +Status: Suspended
 [2017-01-23 13:51 UTC]
Personally, I would prefer to remove such compound operations as
imagecopyresized() and imagecopyresampled(), as imagescale()
already offers improved resizing capabilities, which most likely
will never be backported to the old imagecopyre(sized|sampled)().
The fact that imageflip() is available as of PHP 5.5 only is not
a hindrance anymore, as the active support of PHP 5 has already

Therefore this feature request requires the RFC process[1]. If
anybody still wants this feature, please write to internals; I'm
suspending this ticket for the time being.

Also consider to request this feature for libgd[2]; if it would be
implemented there, allowing PHP to pass negative values to enforce
flipping would be a no-brainer.

[1] <>
[2] <>
 [2021-08-25 13:50 UTC]
-Status: Suspended +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-08-25 13:50 UTC]
Given the lack of further feedback, I'm closing as WONTFIX.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Sep 30 17:01:24 2023 UTC