×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    Make image gallery: Difference between revisions

    Content added Content deleted
    imported>mutante
    mNo edit summary
    imported>mutante
    mNo edit summary
    Line 25: Line 25:
    $image_dir="/home/edgar/public_html/images";
    $image_dir="/home/edgar/public_html/images";
    $thumbs_dir="/home/edgar/public_html/thumbs";
    $thumbs_dir="/home/edgar/public_html/thumbs";
    $html_file="/home/edgar/public_html/index.html";



    # Create a html gallery
    # Create a html gallery
    function mkgallery($image_dir,$thumbs_dir,$html_dir) {
    function mkgallery($image_dir,$thumbs_dir) {


    # HTML Header
    # HTML Header
    Line 61: Line 59:


    # Do it!
    # Do it!
    print mkgallery($image_dir,$thumbs_dir,$html_dir);
    print mkgallery($image_dir,$thumbs_dir);


    ?>
    ?>

    Revision as of 14:19, 23 October 2008

    edgar@cgn:~$ vi mk_gallery.sh
    

    <HighlightSyntax>

    1. !/bin/bash
    2. create image gallery for Edgar
    1. make thumbs

    for file in ~/public_html/images/*

     do convert -size 100 $file ~/public_html/images/thumbs/th-`basename $file`
    

    done

    1. make html

    php /home/edgar/mk_gallery.php > /home/edgar/public_html/index.html

    </HighlightSyntax>

    edgar@cgn:~$ vi mk_gallery.php
     
    
    <?php
    # Make the gallery html for Edgar's image dump
    # mutante / s23
    
    # Pathes to images, thumbnails and the html to be generated
    $image_dir="/home/edgar/public_html/images";
    $thumbs_dir="/home/edgar/public_html/thumbs";
    
    # Create a html gallery
    function mkgallery($image_dir,$thumbs_dir) {
    
    # HTML Header
    $html_head = <<< FNORD
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head><title>Edgar's image gallery</title>
    <meta name="author" content="S23" />
    </head>
    <body>
    FNORD;
    
    # HTML Footer
    $html_foot = <<< FNORD
    <p>Generated by FnordGallery V2.3</p>
    </body>
    </html>
    FNORD;
    
    # HTML Body loop
    
    foreach (glob("$image_dir/*") as $filename) {
    $basename=basename($filename);
    $html_body.="<p><a href=\"./images/$basename\"><img src=\"./images/thumbs/th-$basename\" alt=\"$basename thumbnail\"></img></a> $basename - size ". filesize($filename) ." B </p> \n";
    }
    
    # Give it back!
    $html_output=$html_head.$html_body.$html_foot;
    return $html_output;
    }
    
    # Do it!
    print mkgallery($image_dir,$thumbs_dir);
    
    ?>
    
    edgar@cgn:~$ ./mk_gallery.sh
    

    -> http://cgn.sq23.de/~edgar/

    (valid)

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.