La funcion es la siguiente:
function ShowMediFoto($img){
if(!is_file('../'.$img)) return URL.$img;
$fileinfo=pathinfo($img);
$dir=$fileinfo['dirname']; $name=$fileinfo['basename'];
$mediname='../'.$dir.'/'.P_MEDIFOTO.$name;
if(is_file($mediname)) return $mediname;
$Relacion_AnchoAlto=W_MEDIFOTO/H_MEDIFOTO;
$thumb=new thumbnail(URL.$img); // generamos la imagen en memoria
$Relacion_Imagen=$thumb->img['width']/$thumb->img['height'];
if ($Relacion_AnchoAlto<$Relacion_Imagen) {
$thumb->size_width(W_MEDIFOTO);
} else {
$thumb->size_height(H_MEDIFOTO);
}
$thumb->save($mediname);
if(is_file($mediname)) return $mediname;
return $img;
Y dentro de esta funcion se llama a esta:
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["width"] = imagesx($this->img["src"]);
@$this->img["height"] = imagesy($this->img["src"]);
//default quality jpeg
$this->img["quality"]=75;
Como lo implemento dentro de la pagina para que cuando el usuario introduzca una foto atraves del administrador, esta se redimensione pesar de tener un tamaño desproporcionado?
Ayudadme porfavor, estoy perdido
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)