Reputation: 1300
Hi guys I'm cracking my head on this.
I have a couple of pics, all with different ration (1288x1977
, 1044x1789
e.g).
What I'm trying to do now is to resize the original up to 2 smaller imagines with fixed widths(640 & 1024), but dynamical(percent based i guess) heights, so an original with 1047x1501
would devide into: 1024x1468
and 640x917
, those are the expected results but i can't wrapp my head arround the maths to do this. I hope you can help.
Upvotes: 1
Views: 124
Reputation: 28839
So you want to derive the height from a desired width while maintaining the aspect ratio?
That's math, actually, rather than programming:
Aspect = orig_width / orig_height
Aspect = new_width / new_height
so
orig_width / orig_height = new_width / new_height
so
new_height * (orig_width / orig_height) = new_width
so
new_height = new_width / (orig_width / orig_height)
Upvotes: 4