Viewing file: class_resize.php (1.44 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
class resize {
function resize($archivo, $sz)
{
$this->ARCHIVO = $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);
$copyfile = "../../libreria/gd2/" . $this->ARCHIVO;
$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;
}
if ($ty == 1) {
$dest ="../../libreria/gd2/". $this->ARCHIVO . ".jpg";
}
imagejpeg($img_dst, $dest, 100);
echo "<img src=\"$dest\" border=\"1\">";
}
}
?>
|