×
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
    m (New page: edgar@cgn:~$ vi mk_gallery.sh <HighlightSyntax> #!/bin/bash # create image gallery for Edgar # make thumbs for file in ~/public_html/images/* do convert -size 100 $file ~/public_html/...)
     
    imported>mutante
    mNo edit summary
    Line 17: Line 17:
    edgar@cgn:~$ vi mk_gallery.php
    edgar@cgn:~$ vi mk_gallery.php
    <pre>
    <HighlightSyntax>
    <?php
    <?php
    # Make the gallery html for Edgar's image dump
    # Make the gallery html for Edgar's image dump
    Line 64: Line 64:


    ?>
    ?>
    </pre>
    </HighlightSyntax>


    edgar@cgn:~$ ./mk_gallery.sh
    edgar@cgn:~$ ./mk_gallery.sh

    Revision as of 14:17, 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";
    $html_file="/home/edgar/public_html/index.html";
    
    
    # Create a html gallery
    function mkgallery($image_dir,$thumbs_dir,$html_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,$html_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.