Avatar of markmchugh
markmchugh
 asked on

uploading images + resizing + thumbs etc

Hi,
I want a user of my site to be able to upload images, then i want to create thumbnail images from these. then i want ti display the thumbs and when a user clicks on the image, the image is loaded on the page, is there any good examples or packages that can do this?
PHP

Avatar of undefined
Last Comment
Loganathan Natarajan

8/22/2022 - Mon
JGJacobs

this should work. $file is the image, $width and $height will be the width and height of the thumbnail, $thumbnail will be your generated thumbnail. you will have to save the thumbnail to somewhere on your server once it is generated
$image = imagecreatefromgif( $file );//use this for gif images
$image = imagecreatefromjpeg( $file );//use this for jpeg
$image = imagecreatefrompng( $file );//use for png
$imgAttributes = getimagesize( $file );
$thumbnail = imagecreatetruecolor( $width, $height);
imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $width, $height, $imgAttributes[0], $imgAttributes[1] );

Open in new window

JGJacobs

btw, the above script will only generate the thumbnail
ASKER CERTIFIED SOLUTION
Loganathan Natarajan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck