Hola a todos, estoy usando una class llamada resize para crear dos thumbnails distintos pero al intentar usarlo me sale un error enorme que yo no entiendo ni por asomo que puede ser, os dejo mi código a ver si veis el error.
Código PHP:
<?php
session_start();
require_once("./include/class.inputfilter.php");
$ifilter = new InputFilter();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="perfilcss.css" />
<title>Subida de imágenes</title></head>
<body>
<?php
include('config.php');
$correouser=$ifilter->process($_SESSION['correo']);
?>
<?php
if(isset($_SESSION['correo'])){
$conexion=conectar();
$comprobacion = mysql_query("SELECT * FROM registrados WHERE correo='".mysql_real_escape_string($correouser)."'",$conexion) or die ("Query Fallo".mysql_error());
if( mysql_num_rows($comprobacion) ) {
$row = mysql_fetch_array($comprobacion);
$nombresesion = $row["nombre"];
$apellidossesion = $row["apellidos"];
$idsesion = $row["id"];
}
?>
<div id="menu" class="menu" >
<input type="button" class="bmenu" onclick="location.href='miperfil.php'" value="Vipefy" />
<input type="button" class="bmenu" onclick="location.href='amigos.php'" value=" Mis amigos" />
<input type="button" class="bmenu" onclick="location.href='destruir.php'" value="Desconexión" />
<input type="button" class="bmenu" onclick="location.href='mensajes.php'" value="Mensajes" />
<input type="button" class="bnombre" value="<?php echo $nombresesion." ".$apellidossesion ?>" />
<input type="button" class="bmenuamis" onclick="location.href='newfriends.php'" value="Encontrar amistades" />
</div>
<?php
$status = "";
if ($_POST["action"] == "upload") {
// obtenemos los datos del archivo
$tamano = $_FILES["archivo"]['size'];
$tipo = $_FILES["archivo"]['type'];
$archivo = $_FILES["archivo"]['name'];
$prefijo = $idsesion;
if ($archivo != "") {
// guardamos el archivo a la carpeta imagenes
$destino ='imagenes/'.$prefijo."_".$archivo;
if (copy($_FILES['archivo']['tmp_name'],$destino)) {
$status = "";
$query = "INSERT INTO imagenes (usuario, ruta) ";
$query.="VALUES ('".mysql_real_escape_string($idsesion)."' , '".mysql_real_escape_string($destino)."') ";
$resultado = mysql_query($query, $conexion) or die(mysql_error());
$result = mysql_query("SELECT * FROM imagenes WHERE usuario='".mysql_real_escape_string($idsesion)."'", $conexion);
$row = mysql_fetch_array($result);
$ruta= $row["ruta"];
}
}
}
require_once("./include/resize.php");
$imagenOriginal = $ruta;
/* Un poco reducido */
$img1 = new thumbnail($imagenOriginal);
$img1->size_width(700);
$img1->size_height(500);
$img1->show();
$img1->save("./imagenes/".$ruta."_mediano");
/* Otro tamano thumbnail */
$img2 = new thumbnail($imagenOriginal);
$img2->size_width(100);
$img2->size_height(100);
$img2->show();
$img1->save("./imagenes/".$ruta."_thumb");
?>
</body>
<?php
}else {
header('location:index.php');
}
?>
</html>
Y este es el error que me sale al poner en marcha el script
Código PHP:
jpeg only (0 - 100) (worst - best), default = 75 $thumb->show(); // show your thumbnail $thumb->save("./huhu.jpg"); // save your thumbnail to file ---------------------------------------------- Note : - GD must Enabled - Autodetect file extension (.jpg/jpeg, .png, .gif, .wbmp) but some server can't generate .gif / .wbmp file types - If your GD not support 'ImageCreateTrueColor' function, change one line from 'ImageCreateTrueColor' to 'ImageCreate' (the position in 'show' and 'save' function) */############################################ class thumbnail { var $img; function thumbnail($imgfile) { //detect image format $this->img["format"]=ereg_replace(".*\.(.*)$","\\1",$imgfile); $this->img["format"]=strtoupper($this->img["format"]); if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") { //JPEG $this->img["format"]="JPEG"; $this->img["src"] = ImageCreateFromJPEG ($imgfile); } elseif ($this->img["format"]=="PNG") { //PNG $this->img["format"]="PNG"; $this->img["src"] = ImageCreateFromPNG ($imgfile); } elseif ($this->img["format"]=="GIF") { //GIF $this->img["format"]="GIF"; $this->img["src"] = ImageCreateFromGIF ($imgfile); } elseif ($this->img["format"]=="WBMP") { //WBMP $this->img["format"]="WBMP"; $this->img["src"] = ImageCreateFromWBMP ($imgfile); } else { //DEFAULT echo "Not Supported File"; exit(); } @$this->img["lebar"] = imagesx($this->img["src"]); @$this->img["tinggi"] = imagesy($this->img["src"]); //default quality jpeg $this->img["quality"]=75; } function size_height($size=100) { //height $this->img["tinggi_thumb"]=$size; @$this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"]; } function size_width($size=100) { //width $this->img["lebar_thumb"]=$size; @$this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"]; } function size_auto($size=100) { //size if ($this->img["lebar"]>=$this->img["tinggi"]) { $this->img["lebar_thumb"]=$size; @$this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"]; } else { $this->img["tinggi_thumb"]=$size; @$this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"]; } } function jpeg_quality($quality=75) { //jpeg quality $this->img["quality"]=$quality; } function show() { //show thumb @Header("Content-Type: image/".$this->img["format"]); /* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/ $this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]); @imagecopyresized ($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]); if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") { //JPEG imageJPEG($this->img["des"],"",$this->img["quality"]); } elseif ($this->img["format"]=="PNG") { //PNG imagePNG($this->img["des"]); } elseif ($this->img["format"]=="GIF") { //GIF imageGIF($this->img["des"]); } elseif ($this->img["format"]=="WBMP") { //WBMP imageWBMP($this->img["des"]); } } function save($save="") { //save thumb if (empty($save)) $save=strtolower("./thumb.".$this->img["format"]); /* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/ $this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]); @imagecopyresized ($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]); if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") { //JPEG imageJPEG($this->img["des"],"$save",$this->img["quality"]); } elseif ($this->img["format"]=="PNG") { //PNG imagePNG($this->img["des"],"$save"); } elseif ($this->img["format"]=="GIF") { //GIF imageGIF($this->img["des"],"$save"); } elseif ($this->img["format"]=="WBMP") { //WBMP imageWBMP($this->img["des"],"$save"); } } } ?>
Me sale este texto y este error:
Código PHP:
Fatal error: Class 'thumbnail' not found in C:wampwwwvipefy - copiasubirimagenes.php on line 78
La línea 78 es esta: $img1 = new thumbnail($imagenOriginal);
He revisado si tenía la librería gd activada y si, si que lo está, ademas lo estoy probando en el servidor wamp de localhost.
A ver si sabéis de que viene este error, muchas gracias.