Resizing image
Posted: Tue Nov 08, 2005 8:02 am
I'm trying GD library atm, and for some reason I cannot upload/resize images. Here's what I have:
What am I doing wrong?
Code: Select all
<?php
if (isset($_FILE['img1']))
{
list($width, $height) = getimagesize($_FILE['img1']['tmp_name']);
$new_width = $width * 0.5;
$new_height = $height * 0.5;
$img1 = imagecreatefromjpeg($_FILE['img1']['tmp_name']);
$img1_new = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($img1, $img1_new, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($img1_new, 'images/boogie.jpg');
echo '<img border="0" src="images/boogie.jpg">';
}
?>
<form enctype="multipart/form-data" action="gd.php" method="post">
<input type="file" name="img1"></br>
<input type="submit" value="Go">
</form>