Link to home
Start Free TrialLog in
Avatar of rabbits2
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(strFullPath,"/")
     if intIndex >0 then
         fileOnly ="content/images/" &  Right(strFullPath,Len(strFullPath)-intIndex)
     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.QueryString("photoID")
strFileName = fileOnly(strFile)
strFileName2 = fileOnly(strFile2)

ad=objUpload("txt_picID").value
adid = fileOnly(ad)

str = objUpload("File1").FileName
str2 = objUpload("File2").FileName
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.com/www.piersmooreede.com/web/content/images/" & strFileName1
strPath2 = "D:/sites/piersmooreede.com/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.
ASKER CERTIFIED SOLUTION
Avatar of _Stilgar_
_Stilgar_
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rabbits2
rabbits2

ASKER

If I upload the file in its original state ie full size to my server, are you saying I can then read that image file by:
 Set Image = Server.CreateObject("csImageFile.Manage")
      Image.ReadFile strStorageDir & "\" & strFN
      ImageWidth= Image.Width
      ImageHeight= Image.Height
and then resize it and save it again at the wanted dimensions?
Notice the statement: Set Image = Server.CreateObject("csImageFile.Manage")

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.
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
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.
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.
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_,

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