flying_kiwifruit

used to be bellaandpjforever I had a name change</
Site Supporter
Mar 24, 2006
5,487
220
New Zealand
✟52,205.00
Faith
Non-Denom
Marital Status
Single
Hey

I'm doing a website that has alot of photos on it. All of the photos are really big though and need to be sized down. I know of two ways of doing this using <IMG SCR="Test.gif" with=200 height=350> or however it goes, or going and resizing every image with a image editing program. Both would be very tedious.

I was wondering like you can say in you BODY tags that you want all text white, is there and coding to say that all my images are a certain size.

Thanks
Nat
 

pgp_protector

Noted strange person
Dec 17, 2003
51,759
17,660
56
Earth For Now
Visit site
✟405,128.00
Faith
Christian
Marital Status
Married
Politics
US-Others
The problem with that is you'll still be sending the Full bandwith of the photos to the user.

I.E. If you download a 1000 X 1000 Pixel Image, but resize it via the IMG tags or CCS to 100 X 100, you're still using the 1000 X 1000 Image and it's bandwith / size.

You may be better off using a PHP Script to download / resize your images on the fly.

I.E. <img src="you're url/yourphpscript.php?imgsrc=imglocation">
and yourphpscript.php will use the img manipulation to resize the images on the fly.

Now the drawback to this is depending on your server, and how many viewers you've got, it may put an exsessive load on your CPU cycles (this may only be an issue for shared servers)

Let me see if I can find some code I used for auto resizing images for some work I've done.
 
Upvote 0

pgp_protector

Noted strange person
Dec 17, 2003
51,759
17,660
56
Earth For Now
Visit site
✟405,128.00
Faith
Christian
Marital Status
Married
Politics
US-Others
Ok, I don't know your skill level with PHP Programing, but we used something along this line to rescale our images (we got them from a SQL Database for our application)
Code:
<?
$tbs=255;  //Set Images so they'd be 255 Pixles high you can adjust this as needed
$image = imagecreatefromjpeg('sourceimage.jpg');
$width = imagesx($image); 
$height = imagesy($image);
$scale=$tbs/$height;
$dest_width =(int) $width*$scale; 
$dest_height =(int) $tbs; 
if($tb==0)
	{$dest_img = ImageCreateTrueColor($dest_width, $dest_height); 
	imagecopyresampled($dest_img, $image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height); // resize the image 
	$image=$dest_img;
	}
imagejpeg($image);
};
?>
 
Upvote 0

s3ph

The harsh truth.
Jan 24, 2004
380
17
✟15,602.00
Faith
Atheist
Marital Status
Single
Politics
US-Libertarian
You can use a batch image resizer to set the image resolutions and upload the newly resized images to your server. A quick google search brings up: http://www.fotosizer.com/ which looks acceptable to me.

And if you need the user to have access to fullsize images you can simply upload the fullsize image to the server along with the resized one and make the resized image a link to the fullsize.

If you want to do all this on the fly however, assuming you aren't able to utilize the PHP image resizer posted by pgp protector you could use CSS to meet your needs. It would still tax the server's (and user's) bandwidth and resources with fullsized images, but it should allow you to bypass the tedious work.

Example Code(forgive me if there is an error here. It's late and I haven't done this in a few months):

Include this code(the CSS) within the <head> tags:
Code:
<style type="text/css">
.resize
{ 
height: [B]IMAGEHEIGHT[/B]px;
width: [B]IMAGEWIDTH[/B]px;
}
</style>

Then for every image you would use a format like this:
Code:
<img class="resize" src="[B]IMAGESOURCE[/B]" alt="[B]ALTTEXT[/B]" />
 
Upvote 0