Click to See Complete Forum and Search --> : Image resizer


powerofphp
09-18-2003, 11:53 PM
I have a site in which images are uploaded those images are of different size i mean different width and height. i want a general solution in which if image is of 200 by 300 then it reduce to 150 by 250, or if it is of 500 by 600 then reduce to 200 by 300.
anybody have solution in javascrip or asp or what ever language. waiting for reply

thanx
shams

Khalid Ali
09-19-2003, 08:18 AM
Make sure that image on which you want to perform these actions, is loaded.

e.g

var img = new Image();
img.src = "someimage.gif";

//at this point you should have your image per-loaded.
if(img.width==200){
img.width = 150;
img.height = 300;
}else if(img.width==500){
img.width = 200;
img.height = 300;
}

you can make this code work allot better,however,the idea will remain the same...