GUI Code

  Home arrow GUI Code arrow JPEG Directory thumbnail system
GUI CODE

JPEG Directory thumbnail system
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2003-03-24

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    Creates a set of thumbnails on a page (at a specified size) of JPEG images from a directory.
    Filters out any other files, so can be used in any directory not just a /images one.

    By : rock

    ---------------------------thumbs.php--------------------------

    <?php
    /*
    Will generate a pages width of
    thumbnailed GIF's and JPG's
    from a secified directory. Will work
    in a directory with other files in it
    with no problems.
    Thumbnail variables are set in gen.php

    Generated: 24/3/03
    Author: Rock
    */

    // Comments will be throughout

    // Set variables
    $default_dir = "./images"; // Relative to current location


    // Directory Scan
    if(!($dp = opendir($default_dir))) die("Cannot open $dir");
    // Place images into image tag
    while($file = readdir($dp)){
    if($file != '.' && $file != '..' && stristr($file,"jpg")) echo "<a href=\"$default_dir/$file\"><img src=\"./gen.php?$default_dir/$file\"></a>\r\n";
    }

    closedir($dp);


    ?>
    -----------------------end thumbs.php------------------------

    ------------------------------gen.php----------------------------

    <?php
    /*
    Will generate a pages width of
    thumbnailed GIF's and JPG's
    from a secified directory. Will work
    in a directory with other files in it
    with no problems. Part 2. The image
    creator.
    Aspect ratio is not supported.

    Generated: 24/3/03
    Author: Rock
    */

    // Comments will be throughout

    $t_width = 100; // Thumbnail width
    $t_height = 100; // Thumbnail height

    // get and display jpeg images
    if(stristr($QUERY_STRING,".jpg")){
    header("Content-type: image/jpeg");
    $srcimage = imagecreatefromjpeg($QUERY_STRING);
    $destimage = imagecreate($t_width,$t_height);
    $width = imageSX($srcimage);
    $height = imageSY($srcimage);
    imagecopyresized ($destimage,$srcimage,0,0,0,0,$t_width,$t_height,$width,$height);
    ImageJPEG($destimage);
    ImageDestroy($destimage);
    }
    /*
    //Support for GIF unavailable at this time

    elseif(stristr($QUERY_STRING,".gif")){
    header("Content-type: image/gif");
    $srcimage = imagecreatefromgif($QUERY_STRING);
    $destimage = imagecreate(100,100);
    $width = imageSX($srcimage);
    $height = imageSY($srcimage);
    imagecopyresized ($destimage,$srcimage,0,0,0,0,$t_width,$t_height,$width,$height);
    ImageGIF($destimage);
    ImageDestroy($destimage);
    }
    */

    // on a problem geneterate an image with ERROR in it
    else {
    $im = imagecreate(100,100);
    $blue = imagecolorallocate($im,0,0,200);
    $red = imagecolorallocate($im,255,0,0);
    imagestring($im,2,2,5,"ERROR",$red);
    imageGIF($im);
    imagedestroy($im);
    }

    ?>

    ---------------------------end gen.php-------------------------
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More GUI Code Articles
    More By Codewalkers

    blog comments powered by Disqus

    GUI CODE ARTICLES

    - PHP Image Manipulation Class 1.0
    - Simple PHP-CAPTCHA,
    - dPhoto
    - nice looking dir index'r
    - Colorpicker
    - Exposure Gallery build 1226
    - Dynamic "AQUA" Buttons
    - AdminTool|1.0 for Exposure Gallery
    - Exposure Gallery v1.2
    - Crop Canvas
    - Display all available background colours
    - Exposure Gallery v1.0
    - JPEG Directory Thumbnail system (Apect ratio)
    - JPEG Directory thumbnail system
    - Change Background Color each day

    Developer Shed Affiliates

     



    © 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap