gertjuhhh1993
Gebruiker
- Lid geworden
- 21 jun 2010
- Berichten
- 127
dag mensen ik zit met een probleem. als ik een te groot plaatje heb wil ik em verkleinen en in een variabele weer terug krijgen. het is tot dusver gelukt dat ik de nieuwe image "bouw". alleen hier loop ik op vast:
wat moet ik bij de "imagegif" invullen?
voor een beter overzicht hier de hele pagina. zie lijn 130
Alvast Bedankt
PHP:
imagecopyresized( $thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $image_width, $image_height );
imagegif( $thumb, $_FILES['thumb_image']['tmp_name'] );
voor een beter overzicht hier de hele pagina. zie lijn 130
PHP:
<?php
include("functions.php");
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD Xhtml 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Boeren camping Topperveld</title>
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/lightbox.js"></script>
<link href="css/lightbox.css" rel="stylesheet" />
</head>
<body>
<div id="wrapper">
<div id="header"></div>
<div id="content_left">
<div id="nav">
<div id="nav_menu">
<ul id="menu">
<li><a href="index.php"> <span class="first">H</span><span class="rest">ome</span></a></li>
<li><a href="info.php"> <span class="first">I</span><span class="rest">nfo</span></a></li>
<li><a href="photos.php"> <span class="first">F</span><span class="rest">oto\'s</span></a></li>
<li><a href="contact.php"> <span class="first">C</span><span class="rest">ontact</span></a></li>
</ul>
</div>
</div>
<div id="login">';
if(isset($_SESSION['username']))
{
echo '<p><b>Ingelogd als:</b><br />'. $_SESSION['username'];
echo '<br /><a href="settings.php"><span class="first">I</span><span class="rest">nstellingen</span></a>';
echo '<br /><a href="logout.php"><span class="first">U</span><span class="rest">itloggen</span></a></p>';
}
else
{
echo '<form id="login_form" action="login.php" method="POST">
<label>Gebruikersnaam:</label>
<input type="text" name="username">
<label>Wachtwoord:</label>
<input type="password" name="password">
<input type="submit" name="submit" value="Inloggen">
</form>';
}
?>
</div>
</div>
<div id="page_content">
<?php
if(isset($_POST['submit']))
{
$file = $_FILES['image']['tmp_name'];
}
if(!isset($file))
{
echo "Selecteer een afbeelding";
echo '
<form action="photos-edit.php" method="POST" enctype="multipart/form-data">
<input type="file" name="image"><br />
Beschrijving:<br />
<input type="text" name="image_description"><br />
<input type="submit" name="submit" value="Upload">
</form>';
}
else
{
$image_normal = $_FILES['image']['tmp_name'];
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
$image_description = addslashes($_POST['image_description']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
$image_type= $_FILES['image']['type'];
$image_width = $image_size[0];
$image_height = $image_size[1];
echo $image_width ." X " . $image_height;
$image_max_width = 730;
$image_max_height = 547;
if ($image_width > $image_max_width || $image_height > $image_max_height)
{
// Check the shape of the image.
if( $image_width == $image_height ){ $shape=1; }
if( $image_width < $image_height ){ $shape=2; }
if( $image_width > $image_height ){ $shape=3; }
// Ajusting the resize script on shape.
switch( $shape ){
// Code to resize a square image.
case 1:
$newwidth= 100;
$newheight= 100;
break;
// Code to resize a tall image.
case 2:
$newwidth= 730;
$ratio= $newwidth / $image_width;
$newheight= round( $image_height * $ratio );
break;
// Code to resize a wide image.
case 3:
$newheight= 547;
$ratio= $newheight / $image_height;
$newwidth= round( $image_width * $ratio );
break;
}
// Resizing according to extension.
switch( $image_type ){
// Image/Jpeg
case 'image/jpeg':
$img= imagecreatefromjpeg( $image_normal );
$thumb= imagecreatetruecolor( $newwidth, $newheight );
imagecopyresized( $thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $image_width, $image_height );
break;
// Image/png
case 'image/png':
$img= imagecreatefrompng( $image_normal );
$thumb= imagecreatetruecolor( $newwidth, $newheight );
imagecopyresized( $thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $image_width, $image_height );
imagegif( $thumb, $_FILES['thumb_image']['tmp_name'] );
break;
// Image/gif
case 'image/gif':
$img= imagecreatefromgif( $image_normal );
$thumb= imagecreatetruecolor( $newwidth, $newheight );
imagecopyresized( $thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $image_width, $image_height );
break;
}
}
/*
if ($image_size == FALSE)
{
echo "Dit is geen afbeelding";
}
else
{
if (!$insert = mysql_query("INSERT INTO photos VALUES ('','$image_name','$image','$image_description')"))
{
echo "Het uploaden is niet gelukt. probeert u het nog eens";
}
else
{
header("Location:photos.php");
}
}*/
}
?>
</div>
</div>
</div>
</body>
</html>
Alvast Bedankt
