I have an image which 330 px width and 472 px height . I want to plot this image inn to a bigger canvas which is 55% bigger than the current picture .. How can I fount the final image width and height .
This is more of a math problem than a programming problem. Let's work on it abstractly to get a formula:
Our variables are:
oldWidth, oldHeight, newWidth, newHeight, percentBigger
The original canvas size is
oldCanvasSize = oldWidth * oldHeight
The new canvas size is
newCanvasSize = newWidth + newHeight
55% bigger means 155% or 1.55 so
percent = (percentBigger + 1)
The new canvas is some percent of the old canvas so we have
newCanvasSize = percent * oldCanvasSize
or
newCanvasSize = (percentBigger + 1) * oldCanvasSize
I'll assume we want the proportions to stay the same so
oldWidth / oldHeight = newWidth / newHeight
By substitution and solving the above equations we get
newWidth = SquareRoot(percentBigger + 1) * oldWidth
newHeight = SquareRoot(percentBigger + 1) * oldHeight
I'll let the reader plug in the values.