quiero hacer un thumbnail de una imagen que ya tengo en el servidor, estube probando con los codigos que estan en el faq de php, pero ninguno me resulto
bueno tengo esta funcion
Cita:
y la llamo asifunction thumbnail($file,$dir,$ancho=100,$alto=100,$gif_sup port=false)
{
if(!file_exists($file)){
return false;
}
if(!is_dir($dir)){
return false;
}
$final = (int) strlen($file) - 4;
$nombre = strtolower(substr($file,0,$final));
$ext = strtolower(substr($file,-4,4));
$nombre = $nombre.$ext;
$mini = $dir."/mini_".$nombre;
if($ext==".jpg" || $ext==".jpeg"){
$origen = imageCreateFromJPEG($file);
$imgAncho= imageSx($origen);
$imgAlto = imageSy($origen);
$imagen = imageCreate($ancho,$alto);
ImageCopyResized($imagen,$origen,0,0,0,0,$ancho,$a lto,$imgAncho,$imgAlto);
imageJPEG($imagen,$mini);
}else if($ext==".png"){
$origen = imageCreateFromPNG($file);
$imgAncho= imageSx($origen);
$imgAlto = imageSy($origen);
$imagen = imageCreate($ancho,$alto);
ImageCopyResized($imagen,$origen,0,0,0,0,$ancho,$a lto,$imgAncho,$imgAlto);
imagePNG($imagen,$mini);
}else if(($gif_support==true) && ($ext==".gif")){
$origen = imageCreateFromGIF($file);
$imgAncho= imageSx($origen);
$imgAlto = imageSy($origen);
$imagen = imageCreate($ancho,$alto);
ImageCopyResized($imagen,$origen,0,0,0,0,$ancho,$a lto,$imgAncho,$imgAlto);
imageGIF($imagen,$mini);
}else{
return false;
}
return true;
}
{
if(!file_exists($file)){
return false;
}
if(!is_dir($dir)){
return false;
}
$final = (int) strlen($file) - 4;
$nombre = strtolower(substr($file,0,$final));
$ext = strtolower(substr($file,-4,4));
$nombre = $nombre.$ext;
$mini = $dir."/mini_".$nombre;
if($ext==".jpg" || $ext==".jpeg"){
$origen = imageCreateFromJPEG($file);
$imgAncho= imageSx($origen);
$imgAlto = imageSy($origen);
$imagen = imageCreate($ancho,$alto);
ImageCopyResized($imagen,$origen,0,0,0,0,$ancho,$a lto,$imgAncho,$imgAlto);
imageJPEG($imagen,$mini);
}else if($ext==".png"){
$origen = imageCreateFromPNG($file);
$imgAncho= imageSx($origen);
$imgAlto = imageSy($origen);
$imagen = imageCreate($ancho,$alto);
ImageCopyResized($imagen,$origen,0,0,0,0,$ancho,$a lto,$imgAncho,$imgAlto);
imagePNG($imagen,$mini);
}else if(($gif_support==true) && ($ext==".gif")){
$origen = imageCreateFromGIF($file);
$imgAncho= imageSx($origen);
$imgAlto = imageSy($origen);
$imagen = imageCreate($ancho,$alto);
ImageCopyResized($imagen,$origen,0,0,0,0,$ancho,$a lto,$imgAncho,$imgAlto);
imageGIF($imagen,$mini);
}else{
return false;
}
return true;
}
Cita:
tal como dice en el faq, pero siempre me sale error en creacion de thumbnails.if(!thumbnail("imagen.jpg","imagenes/",80,80)){
echo "error en creacion de thumbnails";
}else{
echo "Creacion exitosa";
}
echo "error en creacion de thumbnails";
}else{
echo "Creacion exitosa";
}
este archivo que tiene el codigo esta en uan carpeta que se llama prueba, y la carpeta imagenes esta en prueba/imagenes y la imagen imagen.jpg esta en la carpeta prueba/imagenes/imagen.jpg nose que estare haciendo mal, el faq decia que esta funcion utiliza la libreria gd y nose si esta instalada en el servidor, el servidor es apache y esta instalado en windows xp, si me puden ayudar se los agradeseria.
Saludos.Chaus.