php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #21470 add imagecopyrotated from latest gd
Submitted: 2003-01-06 14:14 UTC Modified: 2017-01-21 23:34 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:2 (50.0%)
From: gid at gifpaste dot net Assigned: pajoye (profile)
Status: Closed Package: GD related
PHP Version: 4.3.0 OS: Linux
Private report: No CVE-ID: None
 [2003-01-06 14:14 UTC] gid at gifpaste dot net
http://www.boutell.com/gd/ has a patch against php 4.2.3 that adds the imagecopyrotated() function from the gdImageCopyRotated() function that was added in gd 2.0.8.  I would be nice if this were a part of the php tree.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-07 17:35 UTC] pajoye@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Hello,

We strongly recommand the use of the bundled GD, which includes imagerotate.

Thank's for your report.

pierre
 [2003-01-07 19:24 UTC] gid at gifpaste dot net
the imagerotate() function is totally different from the imageCOPYrotated() function that I am referring to.

imagerotate rotates an image

imageCOPYrotate copys an image onto another image while rotating the image that we are copying.  As far as I know, php doesn't allow access to the imageCOPYrotated function in gd > 2.0.8
 [2003-06-24 09:42 UTC] jmaki at andrew dot cmu dot edu
I'd like to add my comments to this bug (to pajoye: it 
does say "feature request" under category, so this does 
seem to be an appropriate place for this)

The built into non-php-gd version of ImageCopyRotated 
is nasty. It has really bad jagged edges and whatnot, 
and doesn't seem to do any cubic/linear sampling of the 
image at all. I think it'd be nice if somebody (maybe 
the author of ImageRotate?) could somehow alter the 
ImageRotate code to work with ImageCopyRotate. 

It's not as trivial as it sounds -- one can't just 
write a wrapper to ImageRotate where a new image is 
allocated for the caller -- ImageCopyRotate makes the 
distinction that if one is rotating an image on top of 
another image, ImageRotate fills the background with a 
given color -- ImageCopyRotated will let the 
destination image show through the transparent portions 
of the source, if any. I need such functionality for my 
app, and I can't seem to find a way with PHP without 
ImageCopyRotated. 

BTW, I did port the non-php-libgd version to PHP just 
for a try, and like I said before, the rotated image it 
makes is nasty. Somebody needs to make it use cubic or 
linear sampling like ImageRotate for better results...
 [2011-01-01 01:21 UTC] jani@php.net
-Package: Feature/Change Request +Package: GD related
 [2017-01-21 23:34 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2017-01-21 23:34 UTC] cmb@php.net
In my opinion, it wouldn't make sense to implement
imagecopyrotated() in ext/gd, because it's not hard to implement
it in userland using imagerotate() which produces results of far
better quality than gdImageCopyRotated().

> […] ImageRotate fills the background with a given color --
> ImageCopyRotated will let the destination image show through the
> transparent portions of the source, if any.

You can choose a transparent color when using imagerotate() to
achieve the same result. An example:

    <?php
    
    // red background
    $back = imagecreatetruecolor(150, 150);
    imagefilledrectangle($back, 0, 0, 149, 149, 0xff0000);

    // green foreground
    $front = imagecreatetruecolor(100, 100);
    imagefilledrectangle($front, 0, 0, 99, 99, 0x00ff00);

    // rotate foreground with transparent filling of missing pixels
    $front = imagerotate($front, 45, 0x7f000000);

    // copy foreground onto background
    imagecopy($back, $front, 5, 5, 0, 0, imagesx($front), imagesy($front));

    // save composition: green diamond on red background
    imagepng($back, __DIR__ . '/21470.png');
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 22:01:26 2024 UTC