primitive Lösung um auf einem Webserver ein paar Bilder anzuzeigen. War eine PHP-Fingerübung.
aaaa.txt
)zzzz.txt
)pb210027.jpg
" eine gleichnamige Textdatei "pb210027.txt
" gibt, wird der Text als Kommentar angezeigt)picturecol
" steuerbarfehlt auch: die Texte ins Exif-Kommentar-Feld umwandeln
das darf auch auf dem Rechner zuhause stattfinden …
#!/bin/bash # 0) dafuer sorgen, dass alle Bilder richtig gedreht sind (ohne das die exif-Informationen # fehlen, z.B. mit flphoto oder exiftran ) # 1) Passende Verkleinerungen basteln #identify -ping *.jpg | awk '{print $3 " " $1}'|awk -F'[' '{print $1}' | sort > filelist.1 #landscape #grosses vorschaubild identify -ping *.jpg | awk '/2272x1704/ {print $1 }'|awk -F'[' '{print $1}' | xargs -i convert {} -resize 568x426 {}.w.568 identify -ping *.jpg | awk '/1280x960/ {print $1 }'|awk -F'[' '{print $1}' | xargs -i convert {} -resize 568x426 {}.w.568 identify -ping *.jpg | awk '/1600x1200/ {print $1 }'|awk -F'[' '{print $1}' | xargs -i convert {} -resize 568x426 {}.w.568 #kleines uebersichtsbild identify -ping *.jpg | awk '/2272x1704/ {print $1 }'|awk -F'[' '{print $1}' | xargs -i convert {} -resize 284x213 {}.w.284 identify -ping *.jpg | awk '/1280x960/ {print $1 }'|awk -F'[' '{print $1}' | xargs -i convert {} -resize 284x213 {}.w.284 identify -ping *.jpg | awk '/1600x1200/ {print $1 }'|awk -F'[' '{print $1}' | xargs -i convert {} -resize 284x213 {}.w.284 #hochkant #grosses vorschaubild identify -ping *.jpg | awk '/1704x2272/ {print $1 }'|awk -F'[' '{print $1}' | xargs -i convert {} -resize 426x568 {}.h.568 identify -ping *.jpg | awk '/960x1280/ {print $1 }'|awk -F'[' '{print $1}' | xargs -i convert {} -resize 426x568 {}.h.568 identify -ping *.jpg | awk '/1200x1600/ {print $1 }'|awk -F'[' '{print $1}' | xargs -i convert {} -resize 426x568 {}.h.568 # kleines uebersichtsbild identify -ping *.jpg | awk '/1704x2272/ {print $1 }'|awk -F'[' '{print $1}' | xargs -i convert {} -resize 213x284 {}.h.284 identify -ping *.jpg | awk '/960x1280/ {print $1 }'|awk -F'[' '{print $1}' | xargs -i convert {} -resize 213x284 {}.h.284 identify -ping *.jpg | awk '/1200x1600/ {print $1 }'|awk -F'[' '{print $1}' | xargs -i convert {} -resize 213x284 {}.h.284 mmv "[a-z][a-z][0-9][0-9][0-9][0-9][0-9][0-9].jpg.[wh].284" "#1#2#3#4#5#6#7#8.284.jpg" mmv "[a-z][a-z][0-9][0-9][0-9][0-9][0-9][0-9].jpg.[wh].568" "#1#2#3#4#5#6#7#8.568.jpg"
Verwendung auf eigene Gefahr!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="various"> <?php $scriptname=basename($_SERVER['PHP_SELF']); $verzeichnisname='.'; $verzeichnis=opendir ($verzeichnisname); ?> <title> <?php $mydir=basename(realpath($verzeichnisname)); echo $mydir; ?> </title> <style type="text/css"> <!-- body {background-color:#ffffff;color:#000000;} a {color:#0000ff;} table { border-top: 1px solid blue; border-bottom: 1px solid blue; padding-top:7px; padding-bottom:7px; /* border-spacing:10px; IE5 doesnt do that .. grr - so I work with empty tr instead. */ } p { font-family: sans-serif;} .bildlink a {color:#999999;font-size:small;} td { padding-top:5px;padding-bottom:5px; vertical-align:top; padding-right:15px} td.bild { padding-top:5px;padding-bottom:5px; } td.descr { background-color:#ffffff; padding-left:5px;padding-right:5px; padding-top:5px;padding-bottom:5px; } --> </style> </head> <body> <h1> <?php echo $mydir; ?> </h1> <p><a href=".."><< back</a> </p> <?php /* Einleitungstext */ if (is_readable("aaaa.txt")) { $fhtextfile = fopen("aaaa.txt","r"); echo "<p>"; while($line = fgets($fhtextfile,500)) { if (chop($line)=="") { echo "</p><p>";} else { echo $line; } } echo "</p>"; fclose($fhtextfile); } /* ende Einleitung */ $verzeichnisname='.'; $imagedir='.'; $verzeichnis=opendir ($verzeichnisname); ?> <table> <tr><td> </td> <td></td> <td></td></tr> <?php while ($datei = readdir($verzeichnis) ) { $dateiliste[] = "$datei"; } sort ( $dateiliste ); $picturecol=2; # number of picture columns $picturecounter=0; #needed for the decision when to start a new row foreach ( $dateiliste as $filename) { if (eregi(".284.jpg",$filename)) { $picturecounter=$picturecounter + 1; $pfad = $verzeichnisname . "/" . $filename ; $filesplit=explode(".",$filename); $filetrunk=$filesplit[0]; if (bcmod($picturecounter,$picturecol) == 1 ) { echo "<tr>"; } ?> <td class="bild"> <?php if (file_exists("$imagedir/$filetrunk.284.jpg")) { if (file_exists("$imagedir/$filetrunk.568.jpg")) { echo "<a href=\"$imagedir/$filetrunk.568.jpg\">"; } echo "<img src=\"$imagedir/$filetrunk.284.jpg\" border=0 alt=\"\">"; if (file_exists("$imagedir/$filetrunk.568.jpg")) { echo "</a>"; } } ?> <!-- </td> <td class=descr> --> <br> <span class="bildlink"> <?php if (file_exists("$imagedir/$filetrunk.568.jpg")) { $showgroesse=bcdiv( filesize("$imagedir/$filetrunk.568.jpg") , 1024 , 1); $showgroesse=bcdiv( ceil($showgroesse*10) , 10 ,1 ); echo "<a href=\"$imagedir/$filetrunk.568.jpg\">größer "; echo"($showgroesse kB)</a> "; } if (file_exists("$imagedir/$filetrunk.jpg")) { $showgroesse=bcdiv( filesize("$imagedir/$filetrunk.jpg") , 1024 , 1); $showgroesse=bcdiv( ceil($showgroesse*10) , 10 ,1 ); echo "<a href=\"$imagedir/$filetrunk.jpg\">Original "; echo "($showgroesse kB))</a>"; } ?> </span> <?php if (is_readable("$filetrunk.txt")) { $fhtextfile = fopen("$filetrunk.txt","r"); echo "<p>"; while($line = fgets($fhtextfile,500)) { if (chop($line)=="") {echo "</p><p>";} else { echo $line; } } echo "</p>"; fclose($fhtextfile); } if (bcmod($picturecounter,$picturecol) == 0) { echo "</td></tr>\n"; echo "<tr><td> <br> </td> <td></td> <td></td></tr>"; } else { echo "</td><td> </td><td>"; } } #if (eregi( } # foreach ( $dateiliste as $filename) closedir($verzeichnis); if (bcmod($picturecounter,$picturecol) != 0) { echo "</td></tr>"; } ?> </table> <?php /* Schlusstext */ if (is_readable("zzzz.txt")) { $fhtextfile = fopen("zzzz.txt","r"); echo "<p>"; while($line = fgets($fhtextfile,500)) { if (chop($line)=="") { echo "</p><p>";} else { echo $line; } } echo "</p>"; fclose($fhtextfile); } /* ende Schlusstext */ ?> <p><a href="../"><< back</a></p> </body> </html>
2007-08-03
gilt für alle Tipps, Tricks & Spickzettel:
dies sind einfache, teils banale Notizen für meinen persönlichen Gebrauch,
die hier eher zufällig auch öffentlich lesbar sind
(vielleicht hilft es ja jemandem weiter). Verwendung auf eigene Gefahr
Fehler-Hinweise, Dankesschreiben , etc. bitte an: web.21@unixwitch.de
weitere Tools / Spickzettel