
16/02/2008, 23:53
|
 | | | Fecha de Ingreso: junio-2006
Mensajes: 550
Antigüedad: 18 años, 9 meses Puntos: 7 | |
Re: Subir Imagen Continuación class.upload.php
Código:
if (is_numeric($this->image_text_y)) {
if ($this->image_text_y < 0) {
$text_y = $this->image_dst_y - $text_height + $this->image_text_y;
} else {
$text_y = $this->image_text_y;
}
} else {
if (strpos($this->image_text_position, 'b') !== false) {
$text_y = $this->image_dst_y - $text_height;
} else if (strpos($this->image_text_position, 't') !== false) {
$text_y = 0;
} else {
$text_y = ($this->image_dst_y - $text_height) / 2;
}
}
// add a background, maybe transparent
if (!empty($this->image_text_background)) {
sscanf($this->image_text_background, "#%2x%2x%2x", $red, $green, $blue);
if ($gd_version >= 2 && (is_numeric($this->image_text_background_percent)) && $this->image_text_background_percent >= 0 && $this->image_text_background_percent <= 100) {
$filter = imagecreatetruecolor($text_width, $text_height);
$background_color = imagecolorallocate($filter, $red, $green, $blue);
imagefilledrectangle($filter, 0, 0, $text_width, $text_height, $background_color);
$this->imagecopymergealpha($image_dst, $filter, $text_x, $text_y, 0, 0, $text_width, $text_height, $this->image_text_background_percent);
imagedestroy($filter);
} else {
$background_color = imagecolorallocate($image_dst ,$red, $green, $blue);
imagefilledrectangle($image_dst, $text_x, $text_y, $text_x + $text_width, $text_y + $text_height, $background_color);
}
}
$text_x += $this->image_text_padding_x;
$text_y += $this->image_text_padding_y;
$t_width = $text_width - (2 * $this->image_text_padding_x);
$t_height = $text_height - (2 * $this->image_text_padding_y);
sscanf($this->image_text_color, "#%2x%2x%2x", $red, $green, $blue);
// add the text, maybe transparent
if ($gd_version >= 2 && (is_numeric($this->image_text_percent)) && $this->image_text_percent >= 0 && $this->image_text_percent <= 100) {
if ($t_width < 0) $t_width = 0;
if ($t_height < 0) $t_height = 0;
$filter = $this->imagecreatenew($t_width, $t_height, false, true);
$text_color = imagecolorallocate($filter ,$red, $green, $blue);
foreach ($text as $k => $v) {
if ($this->image_text_direction == 'v') {
imagestringup($filter,
$this->image_text_font,
$k * ($line_width + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)),
$text_height - (2 * $this->image_text_padding_y) - ($this->image_text_alignment == 'l' ? 0 : (($t_height - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))) ,
$v,
$text_color);
} else {
imagestring($filter,
$this->image_text_font,
($this->image_text_alignment == 'l' ? 0 : (($t_width - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))),
$k * ($line_height + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)),
$v,
$text_color);
}
}
$this->imagecopymergealpha($image_dst, $filter, $text_x, $text_y, 0, 0, $t_width, $t_height, $this->image_text_percent);
imagedestroy($filter);
} else {
$text_color = imageColorAllocate($image_dst ,$red, $green, $blue);
foreach ($text as $k => $v) {
if ($this->image_text_direction == 'v') {
imagestringup($image_dst,
$this->image_text_font,
$text_x + $k * ($line_width + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)),
$text_y + $text_height - (2 * $this->image_text_padding_y) - ($this->image_text_alignment == 'l' ? 0 : (($t_height - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))),
$v,
$text_color);
} else {
imagestring($image_dst,
$this->image_text_font,
$text_x + ($this->image_text_alignment == 'l' ? 0 : (($t_width - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))),
$text_y + $k * ($line_height + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)),
$v,
$text_color);
}
}
}
}
// add a reflection
if ($this->image_reflection_height) {
$this->log .= '- add reflection : ' . $this->image_reflection_height . '<br />';
// we decode image_reflection_height, which can be a integer, a string in pixels or percentage
$image_reflection_height = $this->image_reflection_height;
if (strpos($image_reflection_height, '%')>0) $image_reflection_height = $this->image_dst_y * (str_replace('%','',$image_reflection_height / 100));
if (strpos($image_reflection_height, 'px')>0) $image_reflection_height = str_replace('px','',$image_reflection_height);
$image_reflection_height = (int) $image_reflection_height;
if ($image_reflection_height > $this->image_dst_y) $image_reflection_height = $this->image_dst_y;
if (empty($this->image_reflection_opacity)) $this->image_reflection_opacity = 60;
// create the new destination image
$tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y + $image_reflection_height + $this->image_reflection_space, true);
$transparency = $this->image_reflection_opacity;
// copy the original image
imagecopy($tmp, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y + ($this->image_reflection_space < 0 ? $this->image_reflection_space : 0));
|