note 51444 added to function.getimagesize
| From: | mail at soylentgreens dot com | Date: | Thu, 31 Mar 2005 02:37:15 +0000 |
| Subject: | note 51444 added to function.getimagesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87224@lists.php.net to get a copy of this message | ||
How about this for cropping images...
<?php
$imgfile = "img.jpg";
$cropStartX = 300;
$cropStartY = 250;
$cropW = 200;
$cropH = 200;
// Create two images
$origimg = imagecreatefromjpeg($imgfile);
$cropimg = imagecreatetruecolor($cropW,$cropH);
// Get the original size
list($width, $height) = getimagesize($imgfile);
// Crop
imagecopyresized($cropimg, $origimg, 0, 0, $cropStartX, $cropStartY, $width, $height, $width,
$height);
// TODO: write code to save new image
// or, just display it like this:
header("Content-type: image/jpeg");
imagejpeg($cropimg);
// destroy the images
imagedestroy($cropimg);
imagedestroy($origimg);
?>
----
Manual Page -- http://www.php.net/manual/en/function.getimagesize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51444
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51444&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51444&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51444&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51444&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51444&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51444&report=yes
Search -- http://master.php.net/manage/user-notes.php