...

View Full Version : Image Resizing



Navigator
09-12-2008, 03:41 AM
I would like to resize images, but I do not want to save them resized, I would prefer changing the size by using the <img src='' height='%' width='%' />. I have an image uploader that displays the user's uploaded images, and I don;t want a 500x500 image in a 900 pixel wide space with 2 other images sharing the row.

Is there an easy way to do this?

BigRusky
09-12-2008, 04:08 AM
php is a server side language so you couldnt do that in php, but you should get more help in the javascript forum try there. If u want to store the final size, u could just put that in a table thru php but otherwise php isn't your friend

UrbanTwitch
09-12-2008, 04:23 AM
Google Ajax Image Resize.

Navigator
09-12-2008, 10:09 PM
Well, not exactly...

I have used:



list($width, $height, $type, $attr) = getimagesize($img);


Then between that code and what's below, some code that will take the oversized $width, $height and try to make then make a new width and height that allows the image to keep the same shape, but be correctly sized.

Then...


if($new_width != $width)
{
$width = $new_width;
}
else
{
$width = $width;
}

if($new_height != $height)
{
$height = $new_height;
}
else
{
$height = $height;
}

$img_code = "<img src='$img' alt='User Image' width='$width' height='$height' />";

echo $img_code;

The trouble I am having is getting it so that it keeps it the same shape, but can resize it to be as big as it possibly can without streching the page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum