php.net |  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
Votes:2
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: matteosistisette at gmail dot com
New email:
PHP Version: OS:

 

 [2013-05-16 18:18 UTC] matteosistisette at gmail dot com
Description:
------------
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:
---------------
imagecopyresized($img,$img,0,$h=imagesy($img),0,0,$w=imagesx($img),-$h,$w,$h);

 OR	

imagecopyresized($img,$img,0,0,0,$h=imagesy($img),$w=imagesx($img),$h,$w,-$h);

Expected result:
----------------
image should be flipped vertically

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-20 20:05 UTC] cmb@php.net
-Type: Bug +Type: Feature/Change Request
 [2017-01-23 13:51 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2017-01-23 13:51 UTC] cmb@php.net
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
ended.

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] <http://wiki.php.net/rfc/howto>
[2] <https://github.com/libgd/libgd/issues>
 [2021-08-25 13:50 UTC] cmb@php.net
-Status: Suspended +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-08-25 13:50 UTC] cmb@php.net
Given the lack of further feedback, I'm closing as WONTFIX.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 12:01:27 2024 UTC