SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool help with thumbnail function

    Here is what I have, and it works nicely. But I need help creating the PNG part of it, as of right now it will only create thumbnails for jpgs.

    PHP Code:
    <?php

    function create_thumbnail($image$path) {
        
    $thumb $path "thumb_" $image;
        
    $fullimage $path $image;
        
    copy($image$thumb);

        list(
    $width$height) = getImageSize($image);

        
    $len strlen($thumb);
        
    $pos strpos($thumb,".");
        
    $type substr($thumb,$pos 1,$len); 

        if(
    $width 100) {
            
    $quotient ceil($width/100);
            
    $new_width 100;
            
    $new_height ceil($height/$quotient);
        } else {
            
    $new_width 100;
            
    $new_height $height;
        }

        if(
    $type=="jpeg" || $type=="jpg") {
            
    $destimg ImageCreate($new_width$new_height);

            
    $srcimg ImageCreateFromJPEG($thumb);

            
    ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg));

            
    ImageJPEG($destimg$thumb);
        } 
    }

    ?>
    Any help much appreciated
    Nick . all that we see or seem, is but a dream within a dream
    Show someone you care, send them a virtual flower.
    Good deals on men's watches

  2. #2
    SitePoint Zealot sanka69's Avatar
    Join Date
    Apr 2003
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, for PNG...

    PHP Code:
    $destimg ImageCreate($new_width$new_height); 
    $srcimg ImageCreateFromPNG($thumb); 
    ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srci  mg),ImageSY($srcimg));
    ImagePNG($destimg$thumb); 
    Nick . all that we see or seem, is but a dream within a dream
    Show someone you care, send them a virtual flower.
    Good deals on men's watches


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
  •