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
Image Help (noob)
Moderator: General Moderators
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Image Help (noob)
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)
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.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Image Help (noob)
Apologies, I read your original post as attempting to "scale/resize animage".
Re: Image Help (noob)
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.
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.