Jump to content

Thumbnails pictures uploaded


arbitter

Recommended Posts

I have this site, and momentarely the pictures are way to heavy to have to load every time.

 

http://www.fransdepypere.be/uploads/uploads.php?month=February10&sort=ksort for example.

(I'm not trying to lure people to my site, don't have any ads or anything)

 

Since it's meant to be a site for my grandfather, it's not really that good because his internet is veeeery slooooow. So I'd need to make thumbnails of the pictures uploaded. But what would be the good width? Another advantage of doing this is I wouldn't need the max-width attribute that doesn't work that fine with IE. What would be the good maximum width in pixels for my site, you think?

 

I've searched for some scripts but I don't really find what I like. As a matter of fact, if there's a part about renaming the new file, that isn't neccesary because I only need the thumbnails on my server.

 

I know it's a lot to ask, but i hope someone will give some good advice..

Link to comment
Share on other sites

So I have

 

function resizeImage($originalImage,$toWidth,$toHeight){
    
    // Get the original geometry and calculate scales
    list($width, $height) = getimagesize($originalImage);
    $xscale=$width/$toWidth;
    $yscale=$height/$toHeight;
    
    // Recalculate new size with default ratio
    if ($yscale>$xscale){
        $new_width = round($width * (1/$yscale));
        $new_height = round($height * (1/$yscale));
    }
    else {
        $new_width = round($width * (1/$xscale));
        $new_height = round($height * (1/$xscale));
    }

    // Resize the original image
    $imageResized = imagecreatetruecolor($new_width, $new_height);
    $imageTmp     = imagecreatefromjpeg ($originalImage);
    imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

    return $imageResized;
}

 

But then I don't really know what to do...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.