Miscellaneous
  Home arrow Miscellaneous arrow Page 5 - Creating an Image Gallery
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MISCELLANEOUS

Creating an Image Gallery
By: notepad
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 8
    2003-10-24

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

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    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


       · if your larger images are dead, and you right-click to see the properties of the...
       · ... or#4 - You may not have the gd library properly installed or PHP compiled...
       · At first I was confused as to why TYPE was serialized in config.php only to be...
       · right, it actually says in the tutorial "we'll define an array of valid...
       · *blush* I guess I should have "thoroughly" read through the text...
       · thanks this will help me make my gallery, i already started but this will help me...
       · as i add improvements to this gallery over time, i'll make them available...
       · new bug found that might be causing dead thumbnails.. if the names are odd,...
       · i dunno why i bothered to post that, considering i fixed it, and the post before...
       · Thank you for this great tutorial, it helped my understanding a lot!
       · Thank you for this great tutorial, it helped my understanding a lot!
       · Thank you for this great tutorial, it helped my understanding a lot!
       · alright the old update site has been shutdown. further updates for this gallery...
       · I found that i can't login to this admin panel. The rest of the script works, apart...
       · within your config file, make sure the HOST value is your domain. otherwise it will...
       · if you haven't gotten the updated script from the code library, definately do...
       · Make the thumbs pop up in new window? Some images viewed in full size torture my my...
       · Great tutorial.I am somewhat new to PHP. I managed to get the script working no...
       · Great tutorial.I am somewhat new to PHP. I managed to get the script working no...
       · Hi, im kinda new in PHP, and here is my (must be simple) problem: I putted the hole...
       · so i started over, from scratch. a revised tutorial will be published in phparch.com...
       · adding the revised code to the code section, again. the "new...
       · 
       · error in line "$size = getimagesize($dir.$file);" of...
       · error in line "$size = getimagesize($dir.$file);" of...
       · 
       · 
     

    MISCELLANEOUS ARTICLES

    - Using PHP to Stream MP3 Files and Prevent Il...
    - 10 Must Have Firefox Improvements
    - All About OpenOffice 3.0
    - Shell Script Writing
    - Loops in the UNIX Shell
    - The Test in the UNIX Shell
    - Data Streams and the UNIX Shell
    - Control Mechanisms of the UNIX Shell
    - Variables Within the UNIX Shell
    - The Shell and UNIX
    - In Detail: UNIX File Systems
    - Rights Management in UNIX
    - UNIX File Systems
    - The Terminal in UNIX
    - Operating Systems and UNIX





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT