note 55436 added to ref.image
| From: | MaartenBalliauw at osu1 dot php dot net | Date: | Wed, 03 Aug 2005 14:45:42 +0000 |
| Subject: | note 55436 added to ref.image | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93014@lists.php.net to get a copy of this message | ||
A PHP "skew" function:
<?
$angle = 15;
$pDirection = 1;
header("Content-Type: image/png");
imagepng(ImageSkew("test.png", $angle, 1));
exit();
function ImageSkew($pImage, $pAngle, $pDirection = 0) {
// Source image
$iSource = ImageCreateFromPng("test.png");
// Destination image
list($width, $height, $type, $attr) = getimagesize($pImage);
$iCanvas = @imagecreate($width, $height);
$cCyan = imagecolorallocate($iCanvas, 255, 0, 255);
imagefill($iCanvas, 0, 0, $cCyan);
// Pixel differences
$diff = ($pAngle / 90);
// Loop trough each width pixel
$currentHeight = $height;
$currentY = 0;
if ($pDirection == 1) {
$currentHeight = 0;
$currentY = $height;
}
for ($i = 0; $i < $width; $i++) {
// Take 1*height sample and copy to iCanvas
if ($pDirection == 0) {
imagecopyresampled($iCanvas, $iSource, $i, $currentY, $i, 0, 1, $currentHeight, 1, $height);
} else {
imagecopyresampled($iCanvas, $iSource, ($width - $i), $currentY, ($width - $i), 0, 1,
$currentHeight, 1, $height);
}
// Change heights
if ($pDirection == 0) {
$currentHeight = $currentHeight - ($diff * 2);
$currentY = ($height - $currentHeight) / 2;
} else {
$currentHeight = $height - ( $i * ($diff * 2) );
$currentY = ($height - $currentHeight) / 2;
}
}
// Return
return $iCanvas;
}
?>
----
Manual Page -- http://www.php.net/manual/en/ref.image.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55436
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55436&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55436&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55436&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55436&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55436&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55436&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55436&report=yes
Search -- http://master.php.net/manage/user-notes.php