drisate Posted June 9, 2009 Share Posted June 9, 2009 Hey guys i am trying to resize a flash object but ia m having a hard time finding the logic to retrive the new height after the width resize. $info = getimagesize("uploads/$categ_list[flash]"); if ($info[0] > "645") { $w = "width='645'"; $dif = $info[0] - 645; $height = $info[1] - $dif; $h = "height='$height'"; } This works for the width but not for the height. Any idea? Quote Link to comment Share on other sites More sharing options...
ldougherty Posted June 9, 2009 Share Posted June 9, 2009 I'm not understanding your logic. If width > 645 then dif is width - 645 and height is height - dif? What exactly are you trying to do, resize and maintain the aspect ratio? $info[0] is width $info[1] is height Depending on what you are trying to do ie divide by 645 or subtract 645 etc.. So you had an image and you didn't want that image to be any more than 645 this would work.. if ($info[0] > 645) { $newwidth = 645; $ratio = $info[0] / $newwidth; $newheight = $info[0] / $ratio; } so assume width is 800 and height is 600 ratio is 800/645 which is roughly 1.24 then height is 600 / 1.24 which is 483 so newheight is 483 and you have your new image of 645 x 483 hope that helps. Quote Link to comment Share on other sites More sharing options...
drisate Posted June 9, 2009 Author Share Posted June 9, 2009 Yeah thx bro that did it :-) 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.