Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the image width and height automatically keeping aspect ratio

Status
Not open for further replies.

Adin0605

Technical User
Sep 11, 2009
3
0
0
DE
Hi there,

I have an image uploaded on the website, and I want to generate width and height automatically from a given values(image values in cm).

Ex:
' Image values in cm
Dim strInal as string = 140
Dim strLati as string = 90

Dim strRatio As String
Dim cnstInaltime As Integer
Dim cnstLatime As Integer

' checking to see the image format

If strInal.ToString > strLati.ToString Then
strRatio = Math.Round(strInal / strLati)
cnstInaltime = 15
cnstLatime = 10 * strRatio
End If
If strInal.ToString = strLati.ToString Then
strRatio = 1
cnstInaltime = 5
cnstLatime = 5
End If
If strLati.ToString > strInal.ToString Then
strRatio = Math.Round(strLati / strInal)
cnstInaltime = 10 * strRatio
cnstLatime = 15
End If

Dim intA As Integer = strInal
Dim intB As Integer = strLati

' generating the values in decreasing way

While (intA > 15 Or intB > 15)

intA -= cnstInaltime
intB -= cnstLatime
End While


The code above cannot keep aspect ratio. Any advice would be appreciated.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top