}
if (!empty($this->image_tint_color)) {
$pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));
$r = min(round($tint_red * $pixel['red'] / 169), 255);
$g = min(round($tint_green * $pixel['green'] / 169), 255);
$b = min(round($tint_blue * $pixel['blue'] / 169), 255);
$color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);
imagesetpixel($image_dst, $x, $y, $color);
}
if (!empty($this->image_negative)) {
$pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));
$r = round(255 - $pixel['red']);
$g = round(255 - $pixel['green']);
$b = round(255 - $pixel['blue']);
$color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);
imagesetpixel($image_dst, $x, $y, $color);
}
}
}
}
// adds a border
if ($gd_version >= 2 && !empty($this->image_border)) {
if (is_array($this->image_border)) {
$vars = $this->image_border;
$this->log .= '- add border : ' . implode(' ', $this->image_border) . '<br />';
} else {
$this->log .= '- add border : ' . $this->image_border . '<br />';
$vars = explode(' ', $this->image_border);
}
if (sizeof($vars) == 4) {
$ct = $vars[0]; $cr = $vars[1]; $cb = $vars[2]; $cl = $vars[3];
} else if (sizeof($vars) == 2) {
$ct = $vars[0]; $cr = $vars[1]; $cb = $vars[0]; $cl = $vars[1];
} else {
$ct = $vars[0]; $cr = $vars[0]; $cb = $vars[0]; $cl = $vars[0];
}
if (strpos($ct, '%')>0) $ct = $this->image_dst_y * (str_replace('%','',$ct) / 100);
if (strpos($cr, '%')>0) $cr = $this->image_dst_x * (str_replace('%','',$cr) / 100);
if (strpos($cb, '%')>0) $cb = $this->image_dst_y * (str_replace('%','',$cb) / 100);
if (strpos($cl, '%')>0) $cl = $this->image_dst_x * (str_replace('%','',$cl) / 100);
if (strpos($ct, 'px')>0) $ct = str_replace('px','',$ct);
if (strpos($cr, 'px')>0) $cr = str_replace('px','',$cr);
if (strpos($cb, 'px')>0) $cb = str_replace('px','',$cb);
if (strpos($cl, 'px')>0) $cl = str_replace('px','',$cl);
$ct = (int) $ct;
$cr = (int) $cr;
$cb = (int) $cb;
$cl = (int) $cl;
$this->image_dst_x = $this->image_dst_x + $cl + $cr;
$this->image_dst_y = $this->image_dst_y + $ct + $cb;
if (!empty($this->image_border_color)) sscanf($this->image_border_color, "#%2x%2x%2x", $red, $green, $blue);
// we now create an image, that we fill with the border color
$tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y);
$background = imagecolorallocatealpha($tmp, $red, $green, $blue, 0);
imagefilledrectangle($tmp, 0, 0, $this->image_dst_x, $this->image_dst_y, $background);
// we then copy the source image into the new image, without merging so that only the border is actually kept
imagecopy($tmp, $image_dst, $cl, $ct, 0, 0, $this->image_dst_x - $cr - $cl, $this->image_dst_y - $cb - $ct);
// we transfert tmp into image_dst
$image_dst = $this->imagetransfer($tmp, $image_dst);
}
// add frame border
if (is_numeric($this->image_frame)) {
if (is_array($this->image_frame_colors)) {
$vars = $this->image_frame_colors;
$this->log .= '- add frame : ' . implode(' ', $this->image_frame_colors) . '<br />';
} else {
$this->log .= '- add frame : ' . $this->image_frame_colors . '<br />';
$vars = explode(' ', $this->image_frame_colors);
}
$nb = sizeof($vars);
$this->image_dst_x = $this->image_dst_x + ($nb * 2);
$this->image_dst_y = $this->image_dst_y + ($nb * 2);
$tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y);
imagecopy($tmp, $image_dst, $nb, $nb, 0, 0, $this->image_dst_x - ($nb * 2), $this->image_dst_y - ($nb * 2));
for ($i=0; $i<$nb; $i++) {
sscanf($vars[$i], "#%2x%2x%2x", $red, $green, $blue);
$c = imagecolorallocate($tmp, $red, $green, $blue);
if ($this->image_frame == 1) {
imageline($tmp, $i, $i, $this->image_dst_x - $i -1, $i, $c);
imageline($tmp, $this->image_dst_x - $i -1, $this->image_dst_y - $i -1, $this->image_dst_x - $i -1, $i, $c);
imageline($tmp, $this->image_dst_x - $i -1, $this->image_dst_y - $i -1, $i, $this->image_dst_y - $i -1, $c);
imageline($tmp, $i, $i, $i, $this->image_dst_y - $i -1, $c);
} else {
imageline($tmp, $i, $i, $this->image_dst_x - $i -1, $i, $c);
imageline($tmp, $this->image_dst_x - $nb + $i, $this->image_dst_y - $nb + $i, $this->image_dst_x - $nb + $i, $nb - $i, $c);
imageline($tmp, $this->image_dst_x - $nb + $i, $this->image_dst_y - $nb + $i, $nb - $i, $this->image_dst_y - $nb + $i, $c);
imageline($tmp, $i, $i, $i, $this->image_dst_y - $i -1, $c);
}
}
// we transfert tmp into image_dst
$image_dst = $this->imagetransfer($tmp, $image_dst);
}