Re: image manipulation with php
| From: | Curt Zirzow | Date: | Thu, 31 Aug 2006 07:21:27 +0000 |
| Subject: | Re: image manipulation with php | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-241262@lists.php.net to get a copy of this message | ||
On 8/29/06, Ross <ross@aztechost.com> wrote:
I have an saved images I output with this... <img src="includes/viewphoto.php?id=<?=$photo?>"> I want to use getimagesize() to get the height and width of the image and if it is above a certain size then scale/ reduce it. The problems are (i) using getimage() without a url just my viewphoto.php scriptI'm not sure what you mean here.
(ii) comparing and reducing the filereducing a file tends to follow the logic of some sort: $size = GetImageSize ($image); $ratio = $size[0]/$size[1]; if ($ratio > 1) {
$width = $max_size;
$height = ($max_size/$size[0]) * $size[1];
} else {
$width = ($max_size/$size[1]) * $size[0];
$height = $max_size;
}
where $max_size is the largest you want your image to be in width,
then just copy it it into a new image create at that size
There are a lot of samples of this on google as jochem suggested.
Curt.