SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: image resize

  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    image resize

    Hi i have a php file that outputs images how can i change the size of the images to a smaller version of that image.
    here is the code that im using.

    PHP Code:
     $directory 'thumbs/'.$row['lastname'].'';

    $allowed_types=array('jpg','jpeg','gif','png');
    $file_parts=array();
    $ext='';
    $title='';
    $i=0;

    $dir_handle = @opendir($directory) or die("There is an error with your image directory!");

    while (
    $file readdir($dir_handle)) 
    {
        if(
    $file=='.' || $file == '..') continue;
        
        
    $file_parts explode('.',$file);
        
    $ext strtolower(array_pop($file_parts));

        
    $title implode('.',$file_parts);
        
    $title htmlspecialchars($title);
        
        
    $nomargin='';
        
        if(
    in_array($ext,$allowed_types))
        {
            if((
    $i+1)%4==0$nomargin='nomargin';
        
            echo 
    '
            <div class="pic '
    .$nomargin.'" style="background:url('.$directory.'/'.$file.') no-repeat 50% 50%;">
            <a href="'
    .$directory.'/'.$file.'" title="'.$title.'" target="_blank">'.$title.'</a>
            </div>'
    ;
            
            
    $i++;
        }
    }

    closedir($dir_handle); 
    thankyou

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    What image processing extensions are installed in your PHP configuration? Do you have GD2?

    http://ca2.php.net/imagecopyresized
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi I have
    GD Version bundled (2.0.34 compatible)


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
  •