nisarali23
10-17-2006, 07:28 AM
hi,
I am trying to upload image and resize it autometically. Its happening now, but the problem is its only resizing img by height only and not with the width.
I mean I want it to work in such manner that whatever is the larger (width or height) will resize in ratio.
set imgfile = server.CreateObject("Persits.Jpeg")
imgfile.open uploadsDirVar & "\" & File.ExtractFileName
wd = clng(imgfile.width)
hg = clng(imgfile.height)
ratio = wd / hg
baseratio = 366/291
ratio = clng(ratio)
baseratio = clng(baseratio)
if ratio < basderatio then 'Resize image according to width
imgfile.width = 366
imgfile.height = (hg * 366) / wd
elseif ratio > basderatio then 'Resize image according to height
imgfile.height = 291
imgfile.width = (wd * 291) / hg
else
imgfile.height = 291
imgfile.width = 366
end if
I am trying to upload image and resize it autometically. Its happening now, but the problem is its only resizing img by height only and not with the width.
I mean I want it to work in such manner that whatever is the larger (width or height) will resize in ratio.
set imgfile = server.CreateObject("Persits.Jpeg")
imgfile.open uploadsDirVar & "\" & File.ExtractFileName
wd = clng(imgfile.width)
hg = clng(imgfile.height)
ratio = wd / hg
baseratio = 366/291
ratio = clng(ratio)
baseratio = clng(baseratio)
if ratio < basderatio then 'Resize image according to width
imgfile.width = 366
imgfile.height = (hg * 366) / wd
elseif ratio > basderatio then 'Resize image according to height
imgfile.height = 291
imgfile.width = (wd * 291) / hg
else
imgfile.height = 291
imgfile.width = 366
end if