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
https://forums.phpfreaks.com/topic/193202-thumbnails-pictures-uploaded/
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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.