esto se arregla haciendo thumbnails con este codigo
Código PHP:
function thumbnail($img_origen, $nueva_anchura, $carpeta, $img_destino){
$extension = explode(".",$img_origen);
$ext = count($extension)-1;
if($extension[$ext] == "jpg" || $extension[$ext] == "jpeg")
{
$image = ImageCreateFromJPEG($img_origen);
$tipo=1;
}
else if($extension[$ext] == "gif"){
$image = ImageCreateFromGIF($img_origen);
$tipo=2;
}
else if($extension[$ext] == "png"){
$image = ImageCreateFromPNG($img_origen);
$tipo=3;
}
else
{
return FALSE;
}
$width = imagesx($image);
$height = imagesy($image);
$nueva_altura = ceil($nueva_anchura * $height) / $width ;
if (function_exists("imagecreatetruecolor"))
{
$thumb = ImageCreateTrueColor($nueva_anchura, $nueva_altura);
}
if (!$thumb) $thumb = ImageCreate($nueva_anchura, $nueva_altura);
ImageCopyResized($thumb, $image, 0, 0, 0, 0, $nueva_anchura, $nueva_altura, $width, $height);
switch($tipo){
case 1:
header("Content-type: image/jpeg");
ImageJPEG($thumb, $carpeta.$img_destino, 75);
break;
case 2:
header("Content-type: image/gif");
imagegif($thumb,$carpeta.$img_destino);
break;
case 3:
header("Content-type: image/png");
imagepng($thumb,$carpeta.$img_destino);
break;
}
return TRUE;
}//thumbnail
entonces haces lo siguiente, con el archivo subido
Código PHP:
$nom=$_POST['nombredelaimagen'];
$__carpeta_imgs="../carpetaparaimagenes/";
$__tamanio_thumb=150: //ancho del thumbnail
if(!es_imagen($nom))//comprobamos q sea una imagen con formato permidito
{
header("Location: error.php");
exit;
}
if(file_exists($__carpeta_imgs.$nom))//no podemos subir el archivo si exite uno con el mismo nombre
{
header("Location: error.php");
exit;
}
if(move_uploaded_file($_FILES['nombredelaimagen']['tmp_name'],$__carpeta_imgs.$nom)){
$img_a=$__carpeta_imgs.$nom;//img original
$img_n=$__carpeta_imgs."_t_".$nom;//img thumbnail
$imagen=getimagesize($img_a);
if($imagen[0]>$__tamanio_thumb)//ver si la imagen es mas ancha q lo deseado
thumbnail($img_a,$__tamanio_thumb,"",$img_n);
else
copy($img_a,$img_n);//la copiamos para no tener problemas adelante por flata de archivos
$res=mysql_query("INSERT INTO imagenes (id, nombre) VALUES ('','$nom')")or die("error guradando archivo.<br>".mysql_error());//guardamos el nombre de la imagen
$idarch=mysql_insert_id();//obtenemos el ID de la imagen para ponerlo en el nombre y complicar la repeticion de nombre de archivos
if(file_exists($img_a)){
chmod($img_a,0755);
rename($img_a,$__carpeta_imgs.$idarch."_".$nom);
}
if(file_exists($img_n)){
chmod($img_n,0755);
rename($img_n,$__carpeta_imgs.$idarch."_t_".$nom);
}
}//move_uploaded_file
else{
echo ("Imposible subir el archivo \\\"".$_FILES['archivo']['name']."\\\"");
}
aca tenes una funcion para ver si el archivo subido es una imagen
Código PHP:
function es_imagen($img){
$extension = explode(".",$img);
$ext = count($extension)-1;
if($extension[$ext] == "jpg" || $extension[$ext] == "jpeg" || $extension[$ext] == "gif" || $extension[$ext] == "png")
return TRUE;
else
return FALSE;
}
con todo esto no deberias volver a preocuparte por las miniaturas
espero te sirva
saludos