📄 func.watermark.php
字号:
case 'initial': break; case 'settings1': $arr_config['wm_watermark'] = 1; $arr_config['wm_text'] = "(C) 2004 linpha.sf.net"; $arr_config['wm_fontsize'] = "10"; $arr_config['wm_fontcolor'] = "white"; $arr_config['wm_align'] = "south"; $arr_config['wm_horizontal'] = "0"; $arr_config['wm_vertical'] = "0"; $arr_config['wm_enable_rectangle'] = "1"; $arr_config['wm_rectangle_color'] = "darkgrey"; $arr_config['wm_enable_shadow'] = "2"; $arr_config['wm_height'] = "20"; $arr_config['wm_width'] = "2000"; $arr_config['wm_resize'] = "no"; break; case 'settings2': $arr_config['wm_watermark'] = 2; $arr_config['wm_dissolve'] = "65%"; $arr_config['wm_align'] = "southwest"; $arr_config['wm_img_img'] = "linpha.png"; $arr_config['wm_horizontal'] = "10"; $arr_config['wm_vertical'] = "10"; $arr_config['wm_resize'] = "30"; break; case 'settings3': // maybe better for gd lib than for convert $arr_config['wm_watermark'] = 1; $arr_config['wm_dissolve'] = "100%"; $arr_config['wm_align'] = "southwest"; $arr_config['wm_text'] = "(C) 2004 linpha.sf.net"; $arr_config['wm_fontsize'] = "20"; $arr_config['wm_fontcolor'] = "white"; $arr_config['wm_horizontal'] = "0"; $arr_config['wm_vertical'] = "0"; $arr_config['wm_enable_rectangle'] = "1"; $arr_config['wm_rectangle_color'] = "darkgrey"; $arr_config['wm_enable_shadow'] = "1"; $arr_config['wm_shadow_size'] = "5"; $arr_config['wm_shadow_fontsize'] = "2"; $arr_config['wm_height'] = "30"; $arr_config['wm_width'] = "260"; $arr_config['wm_resize'] = "no"; break; } while(list($name,$value) = each($arr_config) ) { update_config($value, $name); }}function get_html_from_color($string){/*############################################################ used in: get_rgb_from_all()## a list with many available colors##########################################################*/ // http://mail.gnu.org/archive/html/emacs-diffs/2002-06/msg00158.html $rgb = Array ('aliceblue'=>'#f0f8ff', 'antiquewhite'=>'#faebd7', 'aquamarine'=>'#7fffd4', 'azure'=>'#f0ffff', 'beige'=>'#f5f5dc', 'bisque'=>'#ffe4c4', 'black'=>'#000000', 'blanchedalmond'=>'#ffebcd', 'blue'=>'#0000ff', 'blueviolet'=>'#8a2be2', 'brown'=>'#a52a2a', 'burlywood'=>'#deb887', 'cadetblue'=>'#5f9ea0', 'chartreuse'=>'#7fff00', 'chocolate'=>'#d2691e', 'coral'=>'#ff7f50', 'cornflowerblue'=>'#6495ed', 'cornsilk'=>'#fff8dc', 'cyan'=>'#00ffff', 'darkblue'=>'#00008b', 'darkcyan'=>'#008b8b', 'darkgoldenrod'=>'#b886011', 'darkgray'=>'#a9a9a9', 'darkgreen'=>'#006400', 'darkgrey'=>'#a9a9a9', 'darkkhaki'=>'#bdb76b', 'darkmagenta'=>'#8b008b', 'darkolivegreen'=>'#556b2f', 'darkorange'=>'#ff8c00', 'darkorchid'=>'#9932cc', 'darkred'=>'#8b0000', 'darksalmon'=>'#e9967a', 'darkseagreen'=>'#8fbc8f', 'darkslateblue'=>'#483d8b', 'darkslategray'=>'#2f4f4f', 'darkslategrey'=>'#2f4f4f', 'darkturquoise'=>'#00ced1', 'darkviolet'=>'#9400d3', 'deeppink'=>'#ff1493', 'deepskyblue'=>'#00bfff', 'dimgray'=>'#696969', 'dimgrey'=>'#696969', 'dodgerblue'=>'#1e90ff', 'firebrick'=>'#b22222', 'floralwhite'=>'#fffaf0', 'forestgreen'=>'#228b22', 'gainsboro'=>'#dcdcdc', 'ghostwhite'=>'#f8f8ff', 'gold'=>'#ffd700', 'goldenrod'=>'#daa520', 'gray'=>'#bebebe', 'green'=>'#00ff00', 'greenyellow'=>'#adff2f', 'honeydew'=>'#f0fff0', 'hotpink'=>'#ff69b4', 'indianred'=>'#cd5c5c', 'ivory'=>'#fffff0', 'khaki'=>'#f0e68c', 'lavender'=>'#e6e6fa', 'lavenderblush'=>'#fff0f5', 'lawngreen'=>'#7cfc00', 'lemonchiffon'=>'#fffacd', 'lightblue'=>'#add8e6', 'lightcoral'=>'#f08080', 'lightcyan'=>'#e0ffff', 'lightgoldenrod'=>'#eedd82', 'lightgoldenrodyellow'=>'#fafad2', 'lightgray'=>'#d3d3d3', 'lightgreen'=>'#90ee90', 'lightgrey'=>'#d3d3d3', 'lightpink'=>'#ffb6c1', 'lightred'=>'#ffc8c8', 'lightsalmon'=>'#ffa07a', 'lightseagreen'=>'#20b2aa', 'lightskyblue'=>'#87cefa', 'lightslateblue'=>'#8470ff', 'lightslategray'=>'#778899', 'lightsteelblue'=>'#b0c4de', 'lightyellow'=>'#ffffe0', 'limegreen'=>'#32cd32', 'linen'=>'#faf0e6', 'magenta'=>'#ff00ff', 'maroon'=>'#b03060', 'mediumaquamarine'=>'#66cdaa', 'mediumblue'=>'#0000cd', 'mediumorchid'=>'#ba55d3', 'mediumpurple'=>'#9370db', 'mediumseagreen'=>'#3cb371', 'mediumslateblue'=>'#7b68ee', 'mediumspringgreen'=>'#00fa9a', 'mediumturquoise'=>'#48d1cc', 'mediumvioletred'=>'#c71585', 'midnightblue'=>'#191970', 'mintcream'=>'#f5fffa', 'mistyrose'=>'#ffe4e1', 'moccasin'=>'#ffe4b5', 'navajowhite'=>'#ffdead', 'navy'=>'#000080', 'navyblue'=>'#000080', 'oldlace'=>'#fdf5e6', 'olivedrab'=>'#6b8e23', 'orange'=>'#ffa500', 'orangered'=>'#ff4500', 'orchid'=>'#da70d6', 'palegoldenrod'=>'#eee8aa', 'palegreen'=>'#98fb98', 'paleturquoise'=>'#afeeee', 'palevioletred'=>'#db7093', 'papayawhip'=>'#ffefd5', 'peachpuff'=>'#ffdab9', 'peru'=>'#cd853f', 'pink'=>'#ffc0cb', 'plum'=>'#dda0dd', 'powderblue'=>'#b0e0e6', 'purple'=>'#a020f0', 'red'=>'#ff0000', 'rosybrown'=>'#bc8f8f', 'royalblue'=>'#4169e1', 'saddlebrown'=>'#8b4513', 'salmon'=>'#fa8072', 'sandybrown'=>'#f4a460', 'seagreen'=>'#2e8b57', 'seashell'=>'#fff5ee', 'sienna'=>'#a0522d', 'skyblue'=>'#87ceeb', 'slateblue'=>'#6a5acd', 'slategray'=>'#708090', 'slategrey'=>'#708090', 'snow'=>'#fffafa', 'springgreen'=>'#00ff7f', 'steelblue'=>'#4682b4', 'tan'=>'#d2b48c', 'thistle'=>'#d8bfd8', 'tomato'=>'#ff6347', 'turquoise'=>'#40e0d0', 'violet'=>'#ee82ee', 'violetred'=>'#d02090', 'wheat'=>'#f5deb3', 'white'=>'#ffffff', 'yellow'=>'#ffff00', 'yellowgreen'=>'#9acd32' ); if(array_key_exists($string, $rgb)) { $temp_str = $rgb[$string]; return $temp_str; } else { return 0; }}function get_html_color_from_rgb($r,$g,$b){/*###################################### used in: not used anymore####################################*/ if(strlen(dechex($r))==1) { $r = '0'.$r; } else { $r = dechex($r); } if(strlen(dechex($g))==1) { $g = '0'.$g; } else { $g = dechex($g); } if(strlen(dechex($b))==1) { $b = '0'.$b; } else { $b = dechex($b); } return '#'.$r.$g.$b;}function every_char_is_hex($string)/*############################################################ used in: is_html_color## used to check if it is a valid html color##########################################################*/{ for($i=0;$i<strlen($string);$i++) { $char = substr($string,$i,1); $valid_color = false; if($char == "0") { // zero makes problems... '== 0' and '== "0"' is not the same... $valid_color = true; } for($n=1;$n<=9;$n++) { if($char == $n) { $valid_color = true; } } for($n='a';$n<='f';$n++) { if($char === $n) { $valid_color = true; } } for($n='A';$n<='F';$n++) { if($char === $n) { $valid_color = true; } } if(!$valid_color) { return 0; } } return 1;}function is_html_color($string)/*############################################################ used in: get_rgb_from_all## used to check if it is a valid html color##########################################################*/{ switch(strlen($string)) { case 6: if(every_char_is_hex($string)) { return 1; } break; case 7: if(substr($string,0,1)=="#") { if(every_char_is_hex(substr($string,1,6))) { return 1; } } break; } return 0;}function get_rgb_from_html($string){/*############################################################ used in: get_rgb_from_all()## converts a html color to an array with the rgb values## it doesn't matter if the html color is '#00FF00' or '00FF00'##########################################################*/ switch(strlen($string)) { case 6: break; case 7: $string = substr($string,1,6); break; } $r_hex = substr($string,0,2); $g_hex = substr($string,2,2); $b_hex = substr($string,4,2); $arr['r'] = hexdec($r_hex); $arr['g'] = hexdec($g_hex); $arr['b'] = hexdec($b_hex); return $arr;}function get_rgb_from_all($string){/*############################################################ used in: watermark_gd()## returns an array with the rgb values## it doesn't matter if the argument is 'darkblue', '#00FF55' or '00FF55'## if it isn't a correct color, the color (0,0,0) is returned##########################################################*/ $str_rgb = get_html_from_color($string); if(substr($str_rgb,0,1)=="#") { $array_rgb = get_rgb_from_html($str_rgb); } elseif (is_html_color($string)) { $array_rgb = get_rgb_from_html($string); } else { $array_rgb = Array('r'=>0,'g'=>0,'b'=>0); } return $array_rgb;}function calc_align($align, $src_w, $src_h, $dst_w, $dst_h, $pos_x, $pos_y){/*############################################################ used in: watermark_gd()## calcs the position in pixel with a given align## src_w, src_h: width and height from the textfield (or the small watermark image)## dst_w, dst_h: width and height from the image## pos_x, pos_y: additional adjust for the image##########################################################*/ switch($align) { case "center": $arr_pos['x'] = ($dst_w-$src_w)/2+($pos_x); $arr_pos['y'] = ($dst_h-$src_h)/2+($pos_y); break; case "east": $arr_pos['x'] = $dst_w-$src_w+($pos_x); $arr_pos['y'] = ($dst_h-$src_h)/2+($pos_y); break; case "west": $arr_pos['x'] = $pos_x; $arr_pos['y'] = ($dst_h-$src_h)/2+($pos_y); break; case "north": $arr_pos['x'] = ($dst_w-$src_w)/2+($pos_x); $arr_pos['y'] = $pos_y; break; case "south": $arr_pos['x'] = ($dst_w-$src_w)/2+($pos_x); $arr_pos['y'] = $dst_h-$src_h+($pos_y); break; case "northeast": $arr_pos['x'] = $dst_w-$src_w+($pos_x); $arr_pos['y'] = $pos_y; break; case "northwest": $arr_pos['x'] = $pos_x; $arr_pos['y'] = $pos_y; break; case "southwest": $arr_pos['x'] = $pos_x; $arr_pos['y'] = $dst_h-$src_h+($pos_y); break; case "southeast": $arr_pos['x'] = $dst_w-$src_w+($pos_x); $arr_pos['y'] = $dst_h-$src_h+($pos_y); break; default: $arr_pos['x'] = $pos_x; $arr_pos['y'] = $pos_y; break; } return $arr_pos;}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -