jonw118 Posted June 30, 2010 Share Posted June 30, 2010 Hello... I'm not sure how to (if it can be done) restrict an image height ONLY if it is over a certain amount of pixels. Specifically, right now the script resizes images by width only. But sometimes, if an image that is long vertically is uploaded it throws the format off, so in that case, I do want it resize by width AND height, but only in that case. I hope that makes sense. Basically if right now an image is inserted that is 1500px x 1500px I only want it to scale the image width (ie, scaled to 150px wide), keeping the height in proporotion automatically (150px height for this example). But if an image is 1500 x 4000, for example, I'd like it to scale to something like (150px X 150px)... and yes I know it will distort the image, but it will be better than how it breaks the format currently. Is this possible? The specific code I am working with is: <img style='float: center; margin-right: 5px;' width='150px' src='$img' /> Thanks for any suggestions!!! Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 30, 2010 Share Posted June 30, 2010 Yes, it is possible. But, why not specify a max width and a max height. So, for example, if the max size is 150 x 150 the following images would be resized as follows: 1000 x 1000 = 150 x 150 1000 x 3000 = 50 x 150 3000 x 1000 = 150 x 50 You could even "fill in" the unused proportions with black or white. Distorting the image is a bad route IMHO. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.