SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast int3rface's Avatar
    Join Date
    Jun 2003
    Location
    Hull
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    GD libary tutorials

    Just run the phpinfo on my account and it says I have the following:

    GD Support: enabled
    GD Version: 1.6.2 or higher
    FreeType Support: enabled
    FreeType Linkage with: TTF library
    JPG Support: enabled
    PNG Support: enabled
    WBMP Support: enabled

    WHat I wanted to know is can anyone recommend a good tutorial on creating an image gallery with on the fly thumbnails.

    TIA

  2. #2
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Umm....1) www.phpbuilder.com 2) www.devshed.com 3) www.wdvl.com and numerous other sites, though not all tutorials are of decent quality etc

  3. #3
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    /me slaps Dr Livingstone for not mentioning Sitepoint

    http://www.sitepoint.com/article/937
    Haven't read it though (shame on me I know...).
    - website

  4. #4
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    - website

  5. #5
    SitePoint Addict The Mog's Avatar
    Join Date
    Dec 2002
    Location
    Manchester UK
    Posts
    310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IMHO resizing images using the gd lib sucks unless you are using GD2+ then you can use 'imagecreatetruecolor'

    the mog

  6. #6
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Umm... Time I upgraded then ? Website - I'll slap you back remember

  7. #7
    SitePoint Addict The Mog's Avatar
    Join Date
    Dec 2002
    Location
    Manchester UK
    Posts
    310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And finally (20 min later) here is the code you would need

    PHP Code:
    <?
      
    if ($mode == "small") {
        
    $thumbnailsize 100;
      } else if (
    $mode == "medium") {
        
    $thumbnailsize 160;
      } else if (
    $mode == "large") {
        
    $thumbnailsize 350;
      }
      
    $path "images/$file";
      
    $img ImageCreateFromJPEG($path);
      
    $originalX imagesx($img);
      
    $originalY imagesy($img);
      if (
    $originalX $originalY) {
        
    $sf = (double) $thumbnailsize $originalX;
      } else {
        
    $sf = (double) $thumbnailsize $originalY;
      }
      
    $neww $originalX $sf;
      
    $newh $originalY $sf;
      
    $tn ImageCreateTrueColor($neww$newh);
      
    ImageCopyResampled($tn$img0,0,0,0$neww$newh$originalX$originalY);
      
    Header("Content-Type: image/jpeg");
      
    ImageJPEG($tn);
      
    ImageDestroy($tn);
      
    ImageDestroy($img);
    ?>
    call this file something like resize.php and call your image as such
    <img src="resize.php?file=imageName.jpg&mode=small">

    The Mog

  8. #8
    SitePoint Enthusiast int3rface's Avatar
    Join Date
    Jun 2003
    Location
    Hull
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheers for that ;-)

  9. #9
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's all dependant on register_globals though

    add:

    PHP Code:
    $mode $_REQUEST['mode'];
    $file $_REQUEST['file']; 
    to the top of that.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  10. #10
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by The Mog
    IMHO resizing images using the gd lib sucks unless you are using GD2+ then you can use 'imagecreatetruecolor'

    the mog
    I must second that, the new ImageCreateTrueColor() and ImageCopyResampled() are essential, once you see the difference you will never go back! I tried this, had 2 scripts doing exactly the same, the newer one was just so much better then the other one...

    Dr Livingston, yes it is definitely time to change!
    - website

  11. #11
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that's a GD2+ scriptlet as it uses both imagecreatetruecolor and imagecopyresampled. If those functions will not work on your build, I'd suggest reading the sitepoint article linked above which teaches a trick for raising the palette indices from 256 to 16.7million and thus produces much better images.

    If you do have GD2+ you may be interested in a thumbnailing class I also wrote which has a range of effects such as drop shadow, bevel, ellipse, overlay, greyscale etc - located at http://vextron.mirrors.phpclasses.or...kage/1007.html
    teckis - that's news to me.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •