Hier kann eine Notiz zum Merk-Eintrag hinzugefügt werden (optional)
Geschlossen |
<?php function watermark($image, $watermark, $save_as, $position=1, $transparency=1, $t_x=0, $t_y=0) { if($position < 1 || $position > 9) return FALSE; if(!file_exists($image) || !file_exists($watermark)) return FALSE; $infos_img = getimagesize($image); $infos_wat = getimagesize($watermark); if(!in_array($infos_img[2], array(2,3)) || !in_array($infos_wat[2], array(2,3))) return FALSE; if($infos_img[0]<$infos_wat[0] || $infos_img[1]<$infos_wat[1]) return FALSE; if($infos_wat[0]<$t_x || $infos_wat[1]<$t_y) return FALSE; $transparency = 100 - $transparency; if($transpareny < 0 || $transpareny > 100) return FALSE; @unlink($save_as); // Position x switch (($position-1)%3) { case 0: $pos_x = 0; break; case 1: $pos_x = round(($infos_img[0]-$infos_wat[0])/2, 0); break; case 2: $pos_x = $infos_img[0]-$infos_wat[0]; break; } // Position y switch (floor(($position-1)/3)) { case 0: $pos_y = 0; break; case 1: $pos_y = round(($infos_img[1]-$infos_wat[1])/2, 0); break; case 2: $pos_y = $infos_img[1]-$infos_wat[1]; break; } // watermark-procedure if($infos_img[2] == 2) $img_image = imagecreatefromjpeg($image); if($infos_img[2] == 3) $img_image = imagecreatefrompng($image); if($infos_wat[2] == 2) $img_watermark = imagecreatefromjpeg($watermark); if($infos_wat[2] == 3) $img_watermark = imagecreatefrompng($watermark); imagealphablending($img_image, TRUE); imagealphablending($img_watermark, TRUE); imagecolortransparent($img_watermark, imagecolorat($img_watermark, $t_x, $t_y)); imagecopymerge($img_image, $img_watermark, $pos_x, $pos_y, 0, 0 , $infos_wat[0], $infos_wat[1], $transparency); if(strtolower(substr($save_as, -3)) == "png") { if(imagepng($img_image, $save_as)) return TRUE; else return FALSE; } else { if(imagejpeg($img_image, $save_as)) return TRUE; else return FALSE; } return FALSE; } ?>
<?php function watermark($image, $watermark, $save_as, $position = 1, $transparency = 1, $t_x = 0, $t_y = 0) { if ($position < 1 || $position > 9) return false; if (!file_exists($image) || !file_exists($watermark)) return false; $infos_img = getimagesize($image); print_r($infos_img); $infos_wat = getimagesize($watermark); if (!in_array($infos_img[2], array(1, 2, 3)) || !in_array($infos_wat[2], array(1, 2, 3))) return false; if ($infos_img[0] < $infos_wat[0] || $infos_img[1] < $infos_wat[1]) return false; if ($infos_wat[0] < $t_x || $infos_wat[1] < $t_y) return false; $transparency = 100 - $transparency; if ($transpareny < 0 || $transpareny > 100) return false; @unlink($save_as); // Position x switch (($position - 1) % 3) { case 0: $pos_x = 0; break; case 1: $pos_x = round(($infos_img[0] - $infos_wat[0]) / 2, 0); break; case 2: $pos_x = $infos_img[0] - $infos_wat[0]; break; } // Position y switch (floor(($position - 1) / 3)) { case 0: $pos_y = 0; break; case 1: $pos_y = round(($infos_img[1] - $infos_wat[1]) / 2, 0); break; case 2: $pos_y = $infos_img[1] - $infos_wat[1]; break; } // watermark-procedure switch ($infos_img[2]) { case 2: $img_image = imagecreatefromjpeg($image); break; case 3: $img_image = imagecreatefrompng($image); break; case 1: $img_image = imagecreatefromgif($image); break; } switch ($infos_wat[2]) { case 2: $img_watermark = imagecreatefromjpeg($watermark); break; case 3: $img_watermark = imagecreatefrompng($watermark); break; case 1: $img_watermark = imagecreatefromgif($watermark); break; } imagealphablending($img_image, true); imagealphablending($img_watermark, true); imagecolortransparent($img_watermark, imagecolorat($img_watermark, $t_x, $t_y)); imagecopymerge($img_image, $img_watermark, $pos_x, $pos_y, 0, 0, $infos_wat[0], $infos_wat[1], $transparency); $fende = strtolower(substr($save_as, - 3)); if ($fende == 'png') { return imagepng($img_image, $save_as); } elseif ($fende == 'gif') { return imagegif($img_image, $save_as); } else { return imagejpeg($img_image, $save_as); } } ?>
watermark($_FILES['file']['tmp_name'][$k], "logo.png", $bild_url)
move_uploaded_file ( $file_tmpe , $neuer_name);
watermark($file_tmpe, "logo.png", $neuer_name)
require_once('include/includes/func/watermark.php');
if (@move_uploaded_file ($_FILES['file']['tmp_name'], $bild_url))
if (@watermark($_FILES['file']['tmp_name'], 'include/images/watermark/logo.png',$bild_url))
[$k]aus dem normalen watermark-gallery modul, sonst funktioniert es nicht!
Geschlossen | ||
Zurück zu Module und Modifikationen |