Hola GatorV,
no me sale ningun error solo no me muestra la imagen redimensionada.
te pongo el codigo de la libreria de las funciones resize y doprint de la libreria PHPImagen.lib.php
Código PHP:
public function resize($maxancho=null,$maxalto=null,$cut=false) {
if($this->stop())
return;
if($cut != false) $this->cut = true;
$this->mw = (!is_numeric($maxancho) or $maxancho < 1) ? $this->w : intval($maxancho);
$this->mh = (!is_numeric($maxalto) or $maxalto < 1) ? $this->h : intval($maxalto);
$diff_w = $this->w/$this->mw;
$diff_h = $this->h/$this->mh;
if($this->cut == true) {
$this->rh = $this->mh;
$this->rw = $this->mw;
if($diff_w > $diff_h) {
$prop = $this->mh/$this->h;
$this->mw = round($this->w*$prop);
$dist_x = ($this->rw-$this->mw)/2;
} else {
$prop = $this->mw/$this->w;
$this->mh = round($this->h*$prop);
$dist_y = ($this->rh-$this->mh)/2;
}
} else {
if($diff_w > $diff_h) {
$prop = $this->mw/$this->w;
$this->mh = round($this->h*$prop);
} else {
$prop = $this->mh/$this->h;
$this->mw = round($this->w*$prop);
}
$this->rw = $this->mw;
$this->rh = $this->mh;
}
$output = imagecreatetruecolor($this->rw, $this->rh);
if($this->type == "gif" or $this->type == "png") {
$trn_i = imagecolortransparent($this->source);
if ($trn_i >= 0) {
$trn_c = imagecolorsforindex($this->source, $trn_i);
$trn_i = imagecolorallocate($output, $trn_c['red'], $trn_c['green'], $trn_c['blue']);
imagefill($output, 0, 0, $trn_i);
imagecolortransparent($output, $trn_i);
} elseif($this->type == "png") {
imagealphablending($output, false);
$color = imagecolorallocatealpha($output, 0, 0, 0, 127);
imagefill($output, 0, 0, $color);
imagesavealpha($output, true);
}
}
$r = imagecopyresampled($output, $this->source, $dist_x, $dist_y, 0, 0, $this->mw, $this->mh, $this->w, $this->h);
$this->source = $output;
return $r;
}
Código PHP:
public function doPrint($quality=null) {
$quality = (is_numeric($quality) and $quality <= 100 and $quality >= 1) ? intval($quality) : 75;
Header("Content-type: image/".$this->type);
$f2 = $this->f2;
switch($this->type) {
case "gif":
imagegif($this->source);
break;
case "jpeg":
imagejpeg($this->source,null,$quality);
break;
case "png":
$quality = 10 - (round($quality / 10));
imagepng($this->source,null,$quality,PNG_ALL_FILTERS);
break;
}
exit;
}