I am working on a web project which has a lot of images.My requirement is to create thumbnail or to reduce size of Image.
I have two seneraio to create thumbnail.
1)Either I can send full complete Image to clients via REST and client(Web,Mobile) will generate thumbnail in their script.
2)I will send thumbnail generated from Images to REST client(Web,Mobile) so they do not generate any thumbnail from
uploaded file.They will directly receive thumbnail converted image
First one is not an option at all. There is still paid or limited traffic for many clients, and the former approach can cost them a lot. Besides, sending large chunks of data may slow down the overall performance of your app.
If the intention is for users to have thumbnails instead of full images. then it is better to serve thumbnail images rather than serve full images only to resize them client side.
If you don’t want to use an image app to create thumbnails and upload them to your server PHP can create new images easily enough with good results.
Ok to resize at server side an Image What Should I use
right now I am using this code
`$filelocation='old file location';
$newfilelocation='new file location';
$size = getimagesize($filelocation);
$width=$size[0];//might need to be ['1'] im tired .. :)
$height=$size[1];
// Plz note im not sure of units pixles? & i could have the width and height confused
//just had some knee surgery so im kinda loopy :)
$newwidth = 760;
$newheight = $height*($newwidth/$width);
$pic = new Imagick( $filelocation);//specify name
$pic->resizeImage($newwidth,$newhight,Imagick::FILTER_LANCZOS,1);
//again might have width and heing confused
$pic->writeImage($newfilelocation);//output name
$pic->destroy();`
1.create the thumbnails before uploading the images in the first place so as to upload both versions together.
2. Create the thumbnails from the full sized images as soon as the full sized images are uploaded.
3. Create the thumbnalis from the full sized images just prior to sending them to the client for the first time.
Yes, the variable names aren’t the best, hopefully I’ve gotten better since then.
The code used
GD and Image Functions
Yes, agreed.
In my case I was the first user and I didn’t mind the wait.
It’s been 17 years (I did say ancient) and I had a dial-up cnx at the time, but unless my newbie excitement affected my perception of time I don’t remember it taking all that long. (max ~10 thumbnails per page and they were 125x94 created from 400x300)