Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/06/2009, 10:58
biperina
 
Fecha de Ingreso: diciembre-2007
Mensajes: 46
Antigüedad: 16 años, 4 meses
Puntos: 0
Respuesta: Error no encontrado

El error completo es este:

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\xampp\htdocs\php\imagenes.php on line 30


Aqui dejo todo:


function crearThumb( $fuente, $destino, $dim=120, $propor=false, $forzar=true) {
$tipo_imagen = explode( ".", $fuente );
$sizeof = count( $tipo_imagen ) - 1;
$ext = strtolower( $tipo_imagen[$sizeof] );
if ( $ext == "gif" ) {
$fuenteimg = @imagecreatefromgif( $fuente );
}
elseif ( $ext == "png" ) {
$fuenteimg = @imagecreatefrompng( $fuente );
}
else {
$fuenteimg = @imagecreatefromjpeg( $fuente );
}
list( $ancho, $alto, $tipo, $atr ) = getimagesize( $fuente );
if ( $ancho < $dim || $alto > $dim || $forzar ) {
if ( $propor ) {
if ( $ancho > $alto ) {
$nAncho = $dim;
$nAlto = $dim/( $ancho/$alto );
} else {
$nAlto = $dim;
$nAncho = $dim/( $alto/$ancho );
}
} else {
$nAncho = $dim;
$nAlto = $dim;
}
$thumb = imagecreatetruecolor( $nAncho, $nAlto );
imagecopyresampled( $thumb, $fuenteimg, 0, 0, 0, 0, $nAncho, $nAlto, $ancho, $alto );
$calidad = 100;
if ( $ext == "gif" ) {
imagegif( $thumb, $destino, $calidad);
}
elseif ( $ext == "png" ) {
imagepng( $thumb, $destino, $calidad);
}
else {
imagejpeg( $thumb, $destino, $calidad);
}
}
}




Este codigo por cierto lo vi por este foro