Page 1 of 1
Image Help (noob)
Posted: Thu Aug 13, 2009 1:35 pm
by Foxy999
Is it possible to scale/re-size an image as it is being printed on a page? I want to do this instead of resizing the image then storing it on my server.
Also is it possible to return the dimensions of an image?
Foxyy
Re: Image Help (noob)
Posted: Thu Aug 13, 2009 1:44 pm
by aceconcepts
You can use something like this:
Code: Select all
function resize_image($filename, $new_width)
{
$img_size = getimagesize("images/photos/".$filename); //get the original image size
$width=$img_size[0]; //get original image width
$height=$img_size[1]; //get original image height
$new_width=150;
$new_height=floor(($height/$width)*$new_width);
$dimensions=array($new_width, $new_height); //create array of new dimensions
return $dimensions;
}
Re: Image Help (noob)
Posted: Thu Aug 13, 2009 1:58 pm
by Foxy999
I think that will work for getting the dimensions of a scaled image, and the dimensions or the original image, but it doesn't create an image with the new dimensions.
Re: Image Help (noob)
Posted: Thu Aug 13, 2009 2:11 pm
by aceconcepts
Apologies, I read your original post as attempting to "scale/resize animage".
Re: Image Help (noob)
Posted: Thu Aug 13, 2009 3:21 pm
by Foxy999
I want to know if it is able to scale it on the page, without creating a new image.
Also, does that code even re-size the image? It seems like it only create new dimensions that are to scale, but then again I don't know too much about php.