Click to See Complete Forum and Search --> : Persits.jpg width problem


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

so_is_this
11-02-2006, 12:35 AM
<%
MaxDim = 150
If wd > hg Then
hg = Round(MaxDim * (hg / wd))
wd = MaxDim
Else
wd = Round(MaxDim * (wd / hg))
hg = MaxDim
End If
%>

nisarali23
11-02-2006, 12:47 AM
thanks