Viewing file: class_resize.php (1.73 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
class resize {
function resize($archivo, $sz)
{
$this->ARCHIVO = $archivo;
if (file_exists("../../libreria/" . $this->ARCHIVO) and $archivo != "") {
@$size = GetImageSize("../../libreria/" . $this->ARCHIVO);
$an = $size[0];
$la = $size[1];
$ty = $size[2];
$an1 = round($an);
$la1 = round($la);
if ($an > $la) {
$la = $la * $sz;
$la = $la / $an;
$an = $sz;
}
if ($la > $an) {
$an = $an * $sz;
$an = $an / $la;
$la = $sz;
}
if ($la == $an) {
$an = $sz;
$la = $sz;
}
$fl = explode("/", $this->ARCHIVO);
$this->ARCHIVO_2 = $fl[0] . "/" . $sz . $fl[1];
$copyfile = "../../libreria/gd2/" . $this->ARCHIVO_2;
$original_file = $this->ARCHIVO;
@copy("../../libreria/" . $original_file , $copyfile);
if ($ty == 2) {
@$img_src=imagecreatefromjpeg("../../libreria/" . $this->ARCHIVO);
}
if ($ty == 1) {
@$img_src=imagecreatefromgif("../../libreria/" . $this->ARCHIVO);
}
@$img_dst=imagecreatetruecolor($an,$la);
@imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $an, $la, $an1, $la1);
if ($ty == 2) {
$dest ="../../libreria/gd2/". $this->ARCHIVO_2;
}
if ($ty == 1) {
$dest ="../../libreria/gd2/". $this->ARCHIVO_2 . ".jpg";
}
@imagejpeg($img_dst, $dest, 100);
$this->dest = $dest;
}else{
$this->dest = "../../libreria/jpg/n_a.jpg";
}
//echo "<img src=\"$dest\" border=\"1\">";
}
}
?>
|