note 63864 added to function.imagecopy
| From: | php-general at lists dot php dot net | Date: | Sun, 02 Apr 2006 17:21:58 +0000 |
| Subject: | note 63864 added to function.imagecopy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107176@lists.php.net to get a copy of this message | ||
Basic way to implement a "crop" feature : given an image (src), an offset (x, y) and a
size (w, h).
crop.php :
<?php
$w=$_GET['w'];
$h=isset($_GET['h'])?$_GET['h']:$w; // h est facultatif, =w par défaut
$x=isset($_GET['x'])?$_GET['x']:0; // x est facultatif, 0 par défaut
$y=isset($_GET['y'])?$_GET['y']:0; // y est facultatif, 0 par défaut
$filename=$_GET['src'];
header('Content-type: image/jpg');
header('Content-Disposition: attachment; filename='.$src);
$image = imagecreatefromjpeg($filename);
$crop = imagecreatetruecolor($w,$h);
imagecopy ( $crop, $image, 0, 0, $x, $y, $w, $h );
imagejpeg($crop);
?>
Call it like this :
<img src="crop.php?x=10&y=20&w=30&h=40&src=photo.jpg">
----
Server IP: 194.246.101.61
Probable Submitter: 212.194.188.127
----
X-Spam-Status: No, hits=4.8 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_IMAGE_ONLY_06,HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.imagecopy.php
Edit -- http://master.php.net/note/edit/63864
Del: integrated -- http://master.php.net/note/delete/63864/integrated
Del: useless -- http://master.php.net/note/delete/63864/useless
Del: bad code -- http://master.php.net/note/delete/63864/bad+code
Del: spam -- http://master.php.net/note/delete/63864/spam
Del: non-english -- http://master.php.net/note/delete/63864/non-english
Del: in docs -- http://master.php.net/note/delete/63864/in+docs
Del: other reasons-- http://master.php.net/note/delete/63864
Reject -- http://master.php.net/note/reject/63864
Search -- http://master.php.net/manage/user-notes.php