?
Solved

Upload and resize image using Persits ASPJpeg and ASPUpload

Posted on 2007-10-15
6
Medium Priority
?
1,439 Views
Last Modified: 2008-02-25
I urgently need a complete script to upload a file from a form and then resize that image into 2 seperate files. I need a large file 800 x 600 and then a thumbnail 100 x 75. All images should be are 4 x 3 constraint proportions.

To do this I have the following extensions available to me...

Persits ASPJpeg
Persits ASPUpload

Thanks for your help.
0
Comment
Question by:clearchannel
6 Comments
 
LVL 9

Expert Comment

by:deathtospam
ID: 20079777
Have you written any code yet?  If not, the examples in the manuals for each product should help you get started:

===================================================
http://www.aspupload.com/manual.html
http://www.aspjpeg.com/manual.html
===================================================

Of specific interest are the two example:

===================================================
'// Uploading an image to a server.
http://www.aspupload.com/manual_simple.html

'// Creating a thumbnail from an uploaded image.
http://www.aspjpeg.com/manual_02.html#2_1
===================================================


-= DeathToSpam =-
0
 
LVL 9

Accepted Solution

by:
CCongdon earned 2000 total points
ID: 20080029
<%
Dim FileName
Dim FSO
Dim Jpeg
Dim newFile
Dim Upload
Dim UploadedFile

Set Upload = Server.CreateObject("Persits.Upload")
Set Jpeg = Server.CreateObject("Persits.Jpeg")

Upload.OverwriteFiles = False
Upload.Save
FilePath = "D:\upload_location\"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set UploadedFile = Upload.Files(1)
FileName = FilePath & UploadedFile.FileName
UploadedFile.SaveAs FileName
Jpeg.Open UploadedFile.FileName
L = 800
Jpeg.Width = L
Jpeg.Height = Jpeg.OriginalHeight * L / Jpeg.OriginalWidth
Jpeg.Save FilleName
L = 100
Jpeg.Width = L
Jpeg.Height = Jpeg.OriginalHeight * L / Jpeg.OriginalWidth
FileName = FilePath & Replace(UploadedFile.FileName,".jpg","") & "_small.jpg"
Jpeg.Save FilleName
Jpeg.Close()
Set Jpeg = Nothing
Set Upload = Nothing
%>
 

%>
0
 
LVL 9

Expert Comment

by:CCongdon
ID: 20080047
Obvioulsy, ditch the extra %> at the end.

Also, if you have multiple images per page, replace the section in the middle That says:

Set UploadFile = Upload.Files(1)

With:

For Each imageFile in Upload.Files
  Set UploadedFile = imageFile

and put a 'Next' after Jpeg.Close



Oh, and ditch the line that says FSO =, that was an extra piece of my script that I clipped out. I had my script set to make company name and user name directories in the upload area to put the new images into.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:clearchannel
ID: 20080386
Thanks for your help guys. As soon as I test this solution I will award points. :)
0
 
LVL 2

Expert Comment

by:WilliamStam
ID: 20974896
hmmm just a clarification....
Jpeg.Height = Jpeg.OriginalHeight * L / Jpeg.OriginalWidth
Jpeg.Save FilleName

the "FilleName" in that shouldnt that be "Filename"? as no where else is it declaring what file name it should use
0
 
LVL 2

Expert Comment

by:WilliamStam
ID: 20974960
another error... took me a while to figure it out...

the line "Jpeg.Open UploadedFile.FileName" needs to be "Jpeg.Open FileName" as you're already adding the path above.. i think... anyways this seems to make it work.

im kinda changing the code so not sure if the default works or not.. just something i saw that didnt look right
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question