Ich hab schon mal für nen Kollegen sowas gebaut...
Allerdings war es da ne komplette Gallery...
leider werden da die Bilder net abgespeichert, sondern nur temporär erstellt...
Zum abspeichern habe ich allerdings noch eine andere Funktion geschrieben...
es sollte möglich sein, dass man die beiden Quelltexte zusammenbaut und was bei raus kommt, was dann passen tut
Nummero 1:
(hier wir das Bild $m_logo rechts unten auf ein grössere Bild gelegt und das fertige Bild ausgegen (index.php?action=image))
Nummero 2:
Und um TTF schrift zu nutzen geht man wie folgt vor:
Falls gewünscht und falls ich mal mehr Zeit habe kann ich das auch etwas geordneter posten....dann auch mit Comments
ansonten wenn Fragen sind, einfach hier rin ^^
Allerdings war es da ne komplette Gallery...
leider werden da die Bilder net abgespeichert, sondern nur temporär erstellt...
Zum abspeichern habe ich allerdings noch eine andere Funktion geschrieben...
es sollte möglich sein, dass man die beiden Quelltexte zusammenbaut und was bei raus kommt, was dann passen tut
Nummero 1:
(hier wir das Bild $m_logo rechts unten auf ein grössere Bild gelegt und das fertige Bild ausgegen (index.php?action=image))
PHP:
<?php
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| |
| Hausswolff.de (c) 2004 |
| |
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$filename = "index.php";
$m_logo = "http://www.URL.de/p_img/logo.gif";
$gallerytitle = "Wallpaper I";
$thumbhigh = 128;
$pics_in_row = 3;
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$hp_body="
<body link='#000000' alink='#000000' vlink='#000000' topmargin='0' leftmargin='0' text='#000000' bgcolor='#000000'>
";
$hp_banner="
<tr>
<td width='800' height='100' colspan='3' background='http://www.URL.de/p_img/top.jpg'> </td>
</tr>
<tr width='800' height='30' BGCOLOR='#000000'>
<td colspan='3'>
</td>
</tr>
";
$hp_gal_o="
<tr height='440'>
<td> </td>
<td align='center'>
";
$hp_gal_u="
</td>
<td> </td>
</tr>
";
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function get_img_size($file){
$string = getimagesize($file);
return " (".$string[0]." x ".$string[1].")\n";
}
function compressed_output()
{
$encoding = getEnv("HTTP_ACCEPT_ENCODING");
$useragent = getEnv("HTTP_USER_AGENT");
$method = trim(getEnv("REQUEST_METHOD"));
$msie = preg_match("=msie=i", $useragent);
$gzip = preg_match("=gzip=i", $encoding);
if ($gzip && ($method != "POST" or !$msie))
{
ob_start("ob_gzhandler");
return "<small style=\"background: #000000;color: #FFFF93;\">gzip compressed</small>";
}
else
{
ob_start();
return "-|-";
}
}
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
switch($action){
case"viewbig":
?>
<html>
<head>
<title><? echo $files;?></title>
<meta name="author" content="Philipp">
<meta name="generator" content="Ulli Meybohms HTML EDITOR">
</head>
<?php
echo $hp_body;
echo "<center>";
echo "<a href='index.php?start=".$start."'>";
echo "<img height='100%' title='Klicken um wieder zum Index zu kommen' src='index.php?action=image&file=".$file."' border=0 />";
?>
</a>
</center>
</body>
</html>
<?php
break;
case"thumb":
header("Content-Type: image/png");
$imgsrcsz = getimagesize($file);
$newy=$thumbhigh;
$multi = $imgsrcsz[1]/$newy;
$newx = $imgsrcsz[0]/$multi;
$thumb = imagecreatetruecolor($newx, $newy);
switch($imgsrcsz[2]){
case"1":
$imgsrc = imagecreatefromgif($file);
break;
case"2":
$imgsrc = imagecreatefromjpeg($file);
break;
case"2":
$imgsrc = imagecreatefrompng($file);
break;
default:
$imgsrc = imagecreatefromwbmp($file);
}
imagecopyresampled($thumb,$imgsrc,0,0,0,0,$newx,$newy,$imgsrcsz[0],$imgsrcsz[1]);
imageinterlace($thumb,1);
imagepng($thumb,'',75);
imagedestroy($thumb);
break;
case"image":
header("Content-Type: image/jpeg");
$imgsrcsz = getimagesize($file);
$img = imagecreatetruecolor($imgsrcsz[0], $imgsrcsz[1]);
$black = ImageColorAllocate($img, 0, 0, 0);
$white = ImageColorAllocate($img, 255, 255, 255);
$red = ImageColorAllocate($img, 255, 0, 0);
$green = ImageColorAllocate($img, 0, 255, 0);
$blue = ImageColorAllocate($img, 0, 0, 255);
$yellow = ImageColorAllocate($img, 255, 255, 0);
switch($imgsrcsz[2]){
case"1":
$imgsrc = imagecreatefromgif($file);
break;
case"2":
$imgsrc = imagecreatefromjpeg($file);
break;
case"2":
$imgsrc = imagecreatefrompng($file);
break;
default:
$imgsrc = imagecreatefromwbmp($file);
}
imagecopyresampled($img,$imgsrc,0,0,0,0,$imgsrcsz[0],$imgsrcsz[1],$imgsrcsz[0],$imgsrcsz[1]);
$logo = imagecreatefromgif($m_logo);
$logosz = getimagesize($m_logo);
imagecopyresampled($img,$logo,
$imgsrcsz[0]-140,$imgsrcsz[1]-40,
0,0,
135,35,
$logosz[0],$logosz[1]);
imageinterlace($img,1);
imagejpeg($img,'',75);
imagedestroy($img);
break;
default:
?>
<html>
<head>
<title><? echo $gallerytitle;?></title>
<meta name="author" content="Philipp">
<meta name="generator" content="Ulli Meybohms HTML EDITOR">
</head>
<?php
echo $hp_body;
echo "<table align='center'>";
echo $hp_banner;
echo $hp_gal_o;
$count = 1;
$seite = 0;
//index des ordners
$handle=opendir(".");
while ($file = readdir ($handle)) {
if ($file != "." && $file != ".." && $file != "daten" && $file != "bitchs.gif" && $file != "index.php" && $file!="Thumbs.db") {
$files[] = $file;
}
}
closedir($handle);
$anzahl = sizeof($files);
if(!$start){$start=0;}
$ende = $start + 6;
if($ende > $anzahl){$ende = $anzahl;}
echo "<table background='http://www.URL.de/p_img/content.jpg' align='center' width='670'>
<tr><td align='center' colspan=3><big>".$gallerytitle."</big> <small>(".$anzahl." Bilder)<small><hr />\n</td></tr><tr>\n";
for ($j=$start;$j<$ende;$j++)
{
echo "<td width='33%' align=\"center\"><a title=\"".$files[$j]."\" style=\"text-decoration:none\" href=\"index.php?action=viewbig&file=".$files[$j]."&start=".$start."\"><img border=0 src=\"index.php?action=thumb&file=".$files[$j]."\" /><br /><small>".$files[$j]."".get_img_size($files[$j])."</small></a></td>";
if($count%$pics_in_row==0){echo "</tr>\n<tr>\n";}
$count++;
}
if($count%$pics_in_row!=0){echo "</tr>\n";}
echo "<tr><td align='center' colspan=3><hr /></td></tr>\n";
$seiten = ($anzahl-($anzahl%6))/6;
echo "<tr><td align='right' colspan=3><b>Seite »</b> ";
for ($i=0;$i<=$seiten;$i++){
$s = $i*6;
if($s == $start){
echo "<a style='text-decoration:none' href='index.php?start=".$s."'><b><big>[".++$seite."]</big></b></a> ";}
else{
echo "<a style='text-decoration:none' href='index.php?start=".$s."'><small>".++$seite."</small></a> ";}
}
echo "</td></tr></table>\n";
echo $hp_gal_u;
echo "</table>";
?>
</body>
</html>
<?php
}
?>
Nummero 2:
PHP:
<?php
function hp_thumb($folder,$filename,$newy){
$bild = split("\.",$filename);
if(@fopen($folder."/thumb/".$bild[0]."_".$newy.".png","r")){
return "<img title='".$filename."' border=0 src='".$folder."/thumb/".$bild[0]."_".$newy.".png' />";
}
else{
$file = $folder."/".$filename;
$imgsrcsz = getimagesize($file);
$multi = $imgsrcsz[1]/$newy;
$newx = $imgsrcsz[0]/$multi;
$thumb = imagecreatetruecolor($newx, $newy);
switch($imgsrcsz[2]){
case"1":
$imgsrc = imagecreatefromgif($file);
break;
case"2":
$imgsrc = imagecreatefromjpeg($file);
break;
case"2":
$imgsrc = imagecreatefrompng($file);
break;
default:
$imgsrc = imagecreatefromwbmp($file);
}
imagecopyresampled($thumb,$imgsrc,0,0,0,0,$newx,$newy,$imgsrcsz[0],$imgsrcsz[1]);
imageinterlace($thumb,1);
imagepng($thumb,$folder."/thumb/".$bild[0]."_".$newy.".png",75);
imagedestroy($thumb);
return "<img title='".$filename."' border=0 src='".$folder."/thumb/".$bild[0]."_".$newy.".png' />";
}
}
function hp_gallery($stylepack,$start=0){
$pics_in_row = 2;
$out .= "<table width='90%' align='center'>";
$out .= $hp_banner;
$out .= $hp_gal_o;
$count = 1;
$seite = 0;
$handle=opendir("./bilder");
while ($file = readdir ($handle)) {
if ($file != "." && $file != ".." && $file != "klein" && $file != "thumb" && $file != "CVS" && $file!="Thumbs.db") {
$files[] = $file;
}
}
closedir($handle);
$anzahl = sizeof($files);
if(!$start){$start=0;}
$ende = $start + 6;
if($ende > $anzahl){$ende = $anzahl;}
$out .= "<table align='center' width='90%'>
<tr><td align='center' colspan=3><big>Bildergallery</big><small>(".$anzahl." Bilder)<small><hr />\n</td></tr><tr>\n";
for ($j=$start;$j<$ende;$j++)
{
$out .= "<td width='33%' align=\"center\">
<a title=\"".$files[$j]."\" href=\"javascript:void(window.open('show.php?action=view&file=bilder/".$files[$j]."','Bild".$j."','".get_img_size("bilder/".$files[$j],1).",SCROLLBARS=no,RESIZABLE=no,TOOLBAR=NO'))\" onMouseOver=\" self.status = '".$files[$j]." anzeigen lassen'; return true\" onMouseOut=\"self.status=''; return true\" style=\"text-decoration:none\" >".hp_thumb("bilder",$files[$j],150)."<br /><small>".$files[$j]."".get_img_size("bilder/".$files[$j])."</small></a>
<noscript>
<a target='_BILD".$files[$j]."' title=\"".$files[$j]."\" style=\"text-decoration:none\" href=\"bilder/".$files[$j]."\">".hp_thumb("bilder",$files[$j],150)."<br /><small>".$files[$j]."".get_img_size("bilder/".$files[$j])."</small></a>
</noscript>
</td>";
if($count%$pics_in_row==0){$out .= "</tr>\n<tr>\n";}
$count++;
}
if($count%$pics_in_row!=0){$out .= "</tr>\n";}
$out .= "<tr><td align='center' colspan=3><hr /></td></tr>\n";
$seiten = ($anzahl-($anzahl%6))/6;
$out .= "<tr><td align='right' colspan=3><b>Seite »</b> ";
for ($i=1;$i<=$seiten;$i++){
$s = ($i-1)*6;
if($s == $start){
$out .= "<a title='aktuelle Seite (".++$seite.")' style='text-decoration:none' href='index.php?action=gallery&start=".$s."'><b><big>[".$seite."]</big></b></a> ";
}
else{
$out .= "<a title='zur Seite ".++$seite."' style='text-decoration:none' href='index.php?action=gallery&start=".$s."'><small>".$seite."</small></a> ";
}
}
$out .= "</td></tr></table>\n";
return $out;
}
function hp_pic_pod(){
$handle=opendir("./bilder");
while ($file = readdir ($handle)) {
if ($file != "." && $file != ".." && $file != "CVS" && $file != "thumb" && $file != "klein" && $file!="Thumbs.db") {
$files[] = $file;
}
}
closedir($handle);
$pod_id = rand(0,sizeof($files)-1);
return "<a title=\"".$files[$pod_id]."\" href=\"javascript:void(window.open('show.php?action=view&file=bilder/".$files[$pod_id]."','Bild".$j."','".get_img_size("bilder/".$files[$pod_id],1).",SCROLLBARS=no,RESIZABLE=no,TOOLBAR=NO'))\" onMouseOver=\" self.status = '".$files[$pod_id]." anzeigen lassen'; return true\" onMouseOut=\"self.status=''; return true\" style=\"text-decoration:none\" >".hp_thumb("bilder",$files[$pod_id],110)."</a>
<noscript>
<a target='_BILD".$files[$pod_id]."' title=\"".$files[$pod_id]."\" style=\"text-decoration:none\" href=\"bilder/".$files[$pod_id]."\">".hp_thumb("bilder",$files[$pod_id],110)."<small><br /></small>".$files[$pod_id]."".get_img_size("bilder/".$files[$pod_id])."</a>
</noscript>";
}
?>
Und um TTF schrift zu nutzen geht man wie folgt vor:
PHP:
<?php
//schrift festlegen (bei linuxrechnern mit direktem patch
//z.B. /var/www/web2/html/tahomaf)
$font = "tahomaf";
// Bild erstellen mit 520 x 61 pixxeln Bildhandle = $im
$im = ImageCreate(520,61);
//hier werden die Farben definiert...
$black = ImageColorAllocate($im, 0, 0, 0);
$white = ImageColorAllocate($im, 255, 255, 255);
$red = ImageColorAllocate($im, 255, 0, 0);
$green = ImageColorAllocate($im, 0, 255, 0);
$blue = ImageColorAllocate($im, 0, 0, 255);
$yellow = ImageColorAllocate($im, 255, 255, 0);
//Beschriftung festlegen
$header="Beliebiger Text & ".$vars;
//schreiben vom Text an angegebener Stelle
ImageTTFText($im, 8, 0, 5, 61, $black, $font, $header);
//gibt bild als png mit der qualität 80% aus
imagepng($im, "",80);
?>
Falls gewünscht und falls ich mal mehr Zeit habe kann ich das auch etwas geordneter posten....dann auch mit Comments
ansonten wenn Fragen sind, einfach hier rin ^^