![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
16/02/2008, 23:49
|
![Avatar de elfran222](http://static.forosdelweb.com/customavatars/avatar140503_1.gif) | | | Fecha de Ingreso: junio-2006
Mensajes: 550
Antigüedad: 18 años, 8 meses Puntos: 7 | |
Re: Subir Imagen Continuación class.upload.php
Código:
if ($this->image_resize) {
$this->log .= '- resizing...<br />';
if ($this->image_ratio_x) {
$this->log .= ' calculate x size<br />';
$this->image_dst_x = round(($this->image_src_x * $this->image_y) / $this->image_src_y);
$this->image_dst_y = $this->image_y;
} else if ($this->image_ratio_y) {
$this->log .= ' calculate y size<br />';
$this->image_dst_x = $this->image_x;
$this->image_dst_y = round(($this->image_src_y * $this->image_x) / $this->image_src_x);
} else if (is_numeric($this->image_ratio_pixels)) {
$this->log .= ' calculate x/y size to match a number of pixels<br />';
$pixels = $this->image_src_y * $this->image_src_x;
$diff = sqrt($this->image_ratio_pixels / $pixels);
$this->image_dst_x = round($this->image_src_x * $diff);
$this->image_dst_y = round($this->image_src_y * $diff);
} else if ($this->image_ratio || $this->image_ratio_crop || $this->image_ratio_fill || $this->image_ratio_no_zoom_in || $this->image_ratio_no_zoom_out) {
$this->log .= ' check x/y sizes<br />';
if ((!$this->image_ratio_no_zoom_in && !$this->image_ratio_no_zoom_out)
|| ($this->image_ratio_no_zoom_in && ($this->image_src_x > $this->image_x || $this->image_src_y > $this->image_y))
|| ($this->image_ratio_no_zoom_out && $this->image_src_x < $this->image_x && $this->image_src_y < $this->image_y)) {
$this->image_dst_x = $this->image_x;
$this->image_dst_y = $this->image_y;
if ($this->image_ratio_crop) {
if (!is_string($this->image_ratio_crop)) $this->image_ratio_crop = '';
$this->image_ratio_crop = strtolower($this->image_ratio_crop);
if (($this->image_src_x/$this->image_x) > ($this->image_src_y/$this->image_y)) {
$this->image_dst_y = $this->image_y;
$this->image_dst_x = intval($this->image_src_x*($this->image_y / $this->image_src_y));
$ratio_crop = array();
$ratio_crop['x'] = $this->image_dst_x - $this->image_x;
if (strpos($this->image_ratio_crop, 'l') !== false) {
$ratio_crop['l'] = 0;
$ratio_crop['r'] = $ratio_crop['x'];
} else if (strpos($this->image_ratio_crop, 'r') !== false) {
$ratio_crop['l'] = $ratio_crop['x'];
$ratio_crop['r'] = 0;
} else {
$ratio_crop['l'] = round($ratio_crop['x']/2);
$ratio_crop['r'] = $ratio_crop['x'] - $ratio_crop['l'];
}
$this->log .= ' ratio_crop_x : ' . $ratio_crop['x'] . ' (' . $ratio_crop['l'] . ';' . $ratio_crop['r'] . ')<br />';
if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0);
} else {
$this->image_dst_x = $this->image_x;
$this->image_dst_y = intval($this->image_src_y*($this->image_x / $this->image_src_x));
$ratio_crop = array();
$ratio_crop['y'] = $this->image_dst_y - $this->image_y;
if (strpos($this->image_ratio_crop, 't') !== false) {
$ratio_crop['t'] = 0;
$ratio_crop['b'] = $ratio_crop['y'];
} else if (strpos($this->image_ratio_crop, 'b') !== false) {
$ratio_crop['t'] = $ratio_crop['y'];
$ratio_crop['b'] = 0;
} else {
$ratio_crop['t'] = round($ratio_crop['y']/2);
$ratio_crop['b'] = $ratio_crop['y'] - $ratio_crop['t'];
}
$this->log .= ' ratio_crop_y : ' . $ratio_crop['y'] . ' (' . $ratio_crop['t'] . ';' . $ratio_crop['b'] . ')<br />';
if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0);
}
} else if ($this->image_ratio_fill) {
if (!is_string($this->image_ratio_fill)) $this->image_ratio_fill = '';
$this->image_ratio_fill = strtolower($this->image_ratio_fill);
if (($this->image_src_x/$this->image_x) < ($this->image_src_y/$this->image_y)) {
$this->image_dst_y = $this->image_y;
$this->image_dst_x = intval($this->image_src_x*($this->image_y / $this->image_src_y));
$ratio_crop = array();
$ratio_crop['x'] = $this->image_dst_x - $this->image_x;
if (strpos($this->image_ratio_fill, 'l') !== false) {
$ratio_crop['l'] = 0;
$ratio_crop['r'] = $ratio_crop['x'];
} else if (strpos($this->image_ratio_fill, 'r') !== false) {
$ratio_crop['l'] = $ratio_crop['x'];
$ratio_crop['r'] = 0;
} else {
$ratio_crop['l'] = round($ratio_crop['x']/2);
$ratio_crop['r'] = $ratio_crop['x'] - $ratio_crop['l'];
}
$this->log .= ' ratio_fill_x : ' . $ratio_crop['x'] . ' (' . $ratio_crop['l'] . ';' . $ratio_crop['r'] . ')<br />';
if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0);
} else {
$this->image_dst_x = $this->image_x;
$this->image_dst_y = intval($this->image_src_y*($this->image_x / $this->image_src_x));
|