13 private $file =
''; #Archivo de origen
28 $this->filetarget =
$file;
56 $this->addError(_RMS_CF_FILEEMPTY);
59 if ($this->filetarget==
''){
60 $this->addError(_RMS_CF_NOTARGET);
78 if (!file_exists($this->file)){
79 $this->addError(_RMS_CF_FILENOEXISTS);
83 list($wo, $ho) = getimagesize($this->file);
85 $height = $ho * $percent; $width = $wo * $percent;
90 if ($wo==$tw && $ho==$th)
return true;
93 $height = ($tw / $wo) * $ho;
95 $width = ($th / $ho) * $wo;
101 $height = ($tw/ $wo) * $ho;
106 $width = ($th / $ho) * $wo;
109 $thumb = imagecreatetruecolor($width , $height);
110 $bgcolor = imagecolorallocate($thumb, $red, $green, $blue);
111 imagefilledrectangle($thumb, 0, 0, $width, $height, $bgcolor);
112 imagealphablending($thumb,
true);
114 imagecopyresampled($thumb,
$image, 0, 0, 0, 0, $width, $height, $wo, $ho);
115 $thumb2 = imagecreatetruecolor($tw, $th);
117 $bgcolor = imagecolorallocate($thumb2, $red, $green, $blue);
118 imagefilledrectangle($thumb2, 0, 0, $tw , $th , $bgcolor);
119 imagealphablending($thumb2,
true);
121 $w1 =($width/2) - ($tw/2);
122 $h1 = ($height/2) - ($th/2);
124 imagecopyresampled($thumb2, $thumb, 0,0, $w1, $h1, $tw, $th,$tw, $th);
136 $datos = getimagesize($this->file);
137 $ratio = ($datos[0] / $width);
138 $height = round($datos[1] / $ratio);
141 if ($width >= $datos[0]){
142 if ($this->file != $this->filetarget){
143 copy($this->file, $this->filetarget);
149 $thumb = imagecreatetruecolor($width,$height);
150 $bgcolor = imagecolorallocate($thumb, 255,255,255);
151 imagefilledrectangle($thumb, 0, 0, $width, $height, $bgcolor);
152 imagealphablending($thumb,
true);
155 imagecopyresampled ($thumb,
$image, 0, 0, 0, 0, $width, $height, $datos[0], $datos[1]);
168 $datos = getimagesize($this->file);
169 if ($datos[0] >= $datos[1]){
170 $ratio = ($datos[0] / $width);
171 $height = round($datos[1] / $ratio);
173 $ratio = ($datos[1] / $height);
174 $width = round($datos[0] / $ratio);
177 $thumb = imagecreatetruecolor($width,$height);
180 imagecopyresampled ($thumb,
$image, 0, 0, 0, 0, $width, $height, $datos[0], $datos[1]);
191 return imagecreatefromjpeg($this->file);
194 return imagecreatefromgif($this->file);
197 return imagecreatefrompng($this->file);
207 return imagejpeg(
$image, $this->filetarget, $quality);
210 return imagegif(
$image, $this->filetarget);
213 return imagepng(
$image, $this->filetarget);
222 if(preg_match(
"/.jpg/i", $this->file)){
223 $format =
'image/jpeg';
224 }
elseif (preg_match(
"/.gif/i", $this->file)){
225 $format =
'image/gif';
226 }
elseif (preg_match(
"/.png/i", $this->file)){
227 $format =
'image/png';