rabbits2
asked on
Scaling images on Upload where some are Landscape and some portrait
How do to scale the images on upload, as some are landscape and some are portrait therefore I can not simply set the width to 200px as it would mean the portrait might be fine but the landscape at this dimension would be too narrow.
Just to show you what I do at present which contains no scaling or setting dimensions:
<!-- #include file="clsUpload.asp"-->
Dim objUpload
Dim lngFileID
Set objUpload = New clsUpload
function fileOnly(strFullPath)
intIndex=InStrRev(strFullP ath,"/")
if intIndex >0 then
fileOnly ="content/images/" & Right(strFullPath,Len(strF ullPath)-i ntIndex)
else
fileOnly ="content/images/" & strFullPath
end if
end function
strFile = objUpload.Fields("File1"). FileName
Set objField = objUpload("File1")
strFile2 = objUpload.Fields("File2"). FileName
photoid=Request.QueryStrin g("photoID ")
strFileName = fileOnly(strFile)
strFileName2 = fileOnly(strFile2)
ad=objUpload("txt_picID"). value
adid = fileOnly(ad)
str = objUpload("File1").FileNam e
str2 = objUpload("File2").FileNam e
strFileName1 = Left(str, InStrRev(str, ".") - 1) & "_" & ad & "." & Right(str, Len(str) - InStrRev(str, "."))
strFileName3 = Left(str2, InStrRev(str2, ".") - 1) & "_" & ad & "." & Right(str2, Len(str2) - InStrRev(str2, "."))
strPath = "D:/sites/piersmooreede.co m/www.piersmooreede.com/web/content/images/" & strFileName1
strPath2 = "D:/sites/piersmooreede.co m/www.piersmooreede.com/web/content/images/" & strFileName3
strdatabaseName1 = "images/" & strFileName1
strdatabaseName2 = "images/" & strFileName3
objUpload("File1").SaveAs strPath
objUpload("File2").SaveAs strPath2
And then I use an INSERT statement to save this filepath in my database.
Just to show you what I do at present which contains no scaling or setting dimensions:
<!-- #include file="clsUpload.asp"-->
Dim objUpload
Dim lngFileID
Set objUpload = New clsUpload
function fileOnly(strFullPath)
intIndex=InStrRev(strFullP
if intIndex >0 then
fileOnly ="content/images/" & Right(strFullPath,Len(strF
else
fileOnly ="content/images/" & strFullPath
end if
end function
strFile = objUpload.Fields("File1").
Set objField = objUpload("File1")
strFile2 = objUpload.Fields("File2").
photoid=Request.QueryStrin
strFileName = fileOnly(strFile)
strFileName2 = fileOnly(strFile2)
ad=objUpload("txt_picID").
adid = fileOnly(ad)
str = objUpload("File1").FileNam
str2 = objUpload("File2").FileNam
strFileName1 = Left(str, InStrRev(str, ".") - 1) & "_" & ad & "." & Right(str, Len(str) - InStrRev(str, "."))
strFileName3 = Left(str2, InStrRev(str2, ".") - 1) & "_" & ad & "." & Right(str2, Len(str2) - InStrRev(str2, "."))
strPath = "D:/sites/piersmooreede.co
strPath2 = "D:/sites/piersmooreede.co
strdatabaseName1 = "images/" & strFileName1
strdatabaseName2 = "images/" & strFileName3
objUpload("File1").SaveAs strPath
objUpload("File2").SaveAs strPath2
And then I use an INSERT statement to save this filepath in my database.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Notice the statement: Set Image = Server.CreateObject("csIma geFile.Man age")
In ASP Classic you need a component to do that, the code I pasted is a sample for how to do that with a certain component installed, which many hosting services have installed. This can be done with .NET with no prerequisites.
Stilgar.
In ASP Classic you need a component to do that, the code I pasted is a sample for how to do that with a certain component installed, which many hosting services have installed. This can be done with .NET with no prerequisites.
Stilgar.
ASKER
I am using a third party server so should be installed. So the code you posted is all ai need?
If I have to ask the host if the component is installed what is it called?
If that is the case I read the image as you have shown above and then must rezise it.
Could you explain further how I resze the images, or show and example, I am new to this.
Thanks
If I have to ask the host if the component is installed what is it called?
If that is the case I read the image as you have shown above and then must rezise it.
Could you explain further how I resze the images, or show and example, I am new to this.
Thanks
This one is called csImageFile, documented at http://www.chestysoft.com/imagefile/manual.htm.
Whatever component they will have, google for it and see how to use it yourself. It is fairly simple.
Stilgar.
Whatever component they will have, google for it and see how to use it yourself. It is fairly simple.
Stilgar.
ASKER
Sorry I have been doing some reearch and am still very stumped with this one. I spoke to my third party severhosts who cannot tell me whcih asp components are installed on their servers! helpful! Being new to all this I am extreamly lost. What can I do in thsi situation? Using clsUpload alone would not alow me to resize images? Thanks for any further help you can suggest with this one.
ASKER
ok will have a look, thanks
@b0lsc0tt - I provided code and the understanding that a server component is required, and also provided a tool to check for server-side components. If the asker would have resumed communications, he would have recieved further help...
Stilgar.
Stilgar.
_Stilgar_,
Thanks for your comment. I reread this. I probably did pay too much attention to the end of this when I finally made my recommendation. Your first comment does have what is needed for an answer and the Asker did abandon this.
Changed recommendation - Accept: _Stilgar_ {http:#20175642}
Thanks again for the post. Keep up the good work!
b0lsc0tt
EE Cleanup Volunteer
Thanks for your comment. I reread this. I probably did pay too much attention to the end of this when I finally made my recommendation. Your first comment does have what is needed for an answer and the Asker did abandon this.
Changed recommendation - Accept: _Stilgar_ {http:#20175642}
Thanks again for the post. Keep up the good work!
b0lsc0tt
EE Cleanup Volunteer
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
ASKER
Set Image = Server.CreateObject("csIma
Image.ReadFile strStorageDir & "\" & strFN
ImageWidth= Image.Width
ImageHeight= Image.Height
and then resize it and save it again at the wanted dimensions?