need php coding for auto image resizing. The max width i have is 500, sometimes i use images much wider... i need a code to auto adjust the images width to 500, and then auto adjust the height to the correct ratio. Thanks
I can do this for you. how do you want this incorporated? Like in your posting function or gallery...... ect
this will be mainly for posting. Also does this distort the original image quality when the image is resized to fit?
Dont pay for this, it tells you how to do it on the PHP site! And theres and example script! Search this forum, someone posted links to it
I'll give you an HTML / CSS fix . For each image that you are using please use this: <img src="image link" class="imgM" /> HTML: Then add this into your CSS file: .imgM { max-width: 500px; max-height: 500px; } HTML: That should help you out.
As far as I know IE 6 doesn't support this. I can do this script, but I am not sure how to make it work with wordpress.. MSN:
Ok then, this one works for new browsers and IE 5.0 + (apparantly) For each image that you are using please use this: <img src="image link" class="imgM" /> HTML: Then add this into your CSS file: .imgM { max-width: 500px; max-height: 500px; width:expression( document.body.clientWidth > (500/12) * parseInt(document.body.currentStyle.fontSize)? "30em": "auto" ); } HTML: http://www.svendtofte.com/code/max_width_in_ie/
Do you want your images physically resized or just visually resized? With the former bandwidth will be reduced and page load times will decrease but the resized image will be stored on your server. With the latter, however, bandwidth use and load times will remain the same but there is no overhead of creating a copy of the image locally. The latter is the quickest and easier method to implement but both are possible. I could do either for you if you wish. You would not need to assign classes or do anything to images either, it would be done automatically.
The extra ie5.0 + will only work for width, if you want to make it work for height as well, try this: .imgM { max-width: 500px; max-height: 500px; width:expression( document.body.clientWidth > (500/12) * parseInt(document.body.currentStyle.fontSize)? "30em": "auto" ); height:expression( document.body.clientHeight > (500/12) * parseInt(document.body.currentStyle.fontSize)? "30em": "auto" ); } HTML: That's not tested though. This way no PHP is needed, also, you don't have to assign the class either, just use the CSS img {} and that would work.
I only need it for the width. Im a little confused. is this something that i just add once and then the resizing becomes automated? or do i have to do this for each single image i upload? thanks again, youve been very helpful
Ok, just for width, you can try this. I have also changed it so you don't need to add any classes to your images, so it will work straight away. img { max-width: 500px; width:expression( document.body.clientWidth > (500/12) * parseInt(document.body.currentStyle.fontSize)? "30em": "auto" ); } HTML:
But that will add the CSS to EVERY image in the site. If he have a banner, it will resize it. He should probably just need to use class..
Resizing images using height+width reduces the quality, especially for the fact the width might change, but the height won't (so not only will it be distorted due to sizing, but squashed horizontally) If it was PHP resized it would come out better (as in it actually resized - it takes the old image, generates a new one - so if the width is 75% then the height is 75% also, and then that overwrites the old image)
Here's an image resized using your method. Original on the left, resized on the right. http://img57.imageshack.us/img57/6850/resizegv6.jpg Thats using a 100% quality JPG image (both the Ninja, and the image I have above) That's a small image too - if it was a big image then you would be able to see the distortion even more. Like I said, the quality isn't good. Unless you want to argue that it is of course... EDIT: It does seem to resize both ways, last time I used HTML or CSS to resize images was before CSS2 was even supported by the browser on my powerhouse Windows 95 machine. The quality still looks as rubbish as it did back then though (some things never seem to advance quickly), so its not as good a solution as PHP.