Miscellaneous

  Home arrow Miscellaneous arrow Page 5 - Creating an Image Gallery
MISCELLANEOUS

Creating an Image Gallery
By: notepad
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2003-10-24

    Table of Contents:
  • Creating an Image Gallery
  • getting started
  • moving along
  • review and organize
  • thumbnails
  • conclusion

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Creating an Image Gallery - thumbnails


    (Page 5 of 6 )

    the last portion of the project we'll discuss is imgsrc.php, this script will be called with the full path to an image via a variable called $src, and it will then output a thumbnail of that image according to our specified thumbnail width/height. you may notice some similarities between the following code and Michael Bailey's tutorial on thumbnails. he has written an excellent tutorial which i've borrowed from and therefore won't bother providing a lot of comments about what the code is doing here. feel free to read through his tutorial should you have any questions about this portion of the project.

    <?php

    require_once('config.php');

    $src = isset($_REQUEST['src']) ? urldecode($_REQUEST['src']) : null;

    // we're using file_exists here to prevent working with remote files
    if(isset($src) && file_exists($src))
    {
        header('Content-Type: image/jpeg');

        list($width, $height, $type, $attr) = getimagesize($src);
        $img = imagecreatefromjpeg($src);
        $lowest = min(THMBWIDTH / $width, THMBHEIGHT / $height);

        if($lowest < 1)
        {
        $smallwidth = floor($lowest*$width);
        $smallheight = floor($lowest*$height);
        $tmp = imagecreatetruecolor($smallwidth, $smallheight);
        imagecopyresized($tmp, $img, 0, 0, 0, 0, $smallwidth, $smallheight, $width, $height);
        imagedestroy($img);
        $img = $tmp;
        }
        imagejpeg($img, '', 100);
        imagedestroy($img);
    }

    ?>

    More Miscellaneous Articles
    More By notepad

    blog comments powered by Disqus

    MISCELLANEOUS ARTICLES

    - Oracle Database XE: Indexes and Sequences
    - Modifying Tables in Oracle Database XE
    - Oracle Database XE: Tables and Constraints
    - More on Oracle Databases and Datatypes
    - Oracle Database XE Datatypes: Datetime and L...
    - Oracle Database XE Datatypes: Character and ...
    - From Databases to Datatypes
    - Firefox 3.6.6 Released with Improved Plug-in...
    - Attention Bloggers: WordPress 3.0 Now Releas...
    - Reflection in PHP 5
    - Inheritance and Other Advanced OOP Features
    - Advanced OOP Features
    - Linux from Scratch V.6.6 Review
    - Linux Gaining in Strength
    - Install Slackware on Your Old PC


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