Jump to content

Image resizing


The Sea King
 Share

Recommended Posts

Don't believe javascript resizes images... you can use the height/width attribute of an image tag to have the image displayed smaller, but you need a server side language to resize the image if i'm not mistaken.

Link to comment
Share on other sites

You can "resize" an image using JS to modify its height and width, but it will look weird as there will not be interpolation, as it gets smaller pixels will just be sacrificed, making the image look jagged. You can use PHP's GD image functions to smoothly resize an image.

Link to comment
Share on other sites

Something like this will do then (images you want to resize give a class of small)

function setsizes() {	images = document.getElementsByTagName('img');	for (i = 0; i < images.length; i++) {		img = images[i];		if (img.className == "small") {			if (img.height > 640 || img.width > 480) {				if (img.height > 3 * (img.width / 4)) img.style.height = "480px";				else img.style.width = "640px";			}		}	}}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...