Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old October 3rd, 2006, 09:10 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information.
 
Join Date: Sep 2004
Location: Israel
Posts: 26,621 Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)  Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 4 Days 13 h 47 m 29 sec
Reputation Power: 1441
Image Resize Part II - resize image on the fly

Attached is aspx file that can resize given image on the fly to the
desired width and/or height.

Credits for the code go to GunBlade who developed the core logic.

To use the code and resize image, follow those steps:
  1. get server that support ASP.NET
  2. on that server, copy the aspx file as is.
  3. browse to the aspx file in such manner:
    Code:
    http://localhost/ImageResizer.aspx?image=[full image path here]&thumb=[full path of thumbnail to be created here]&width=[desired width]&height=[desired height]
  4. if you have desired width only and would like the height
    calculated automatically, then pass -1 as the height.
  5. if you have desired height only and would like the width
    calculated automatically, then pass -1 as the width.
  6. for example, suppose you got image called "house.jpg" in
    folder named "Images" and you want it resized to 500 pixels
    width:
    Code:
    http://localhost/ImageResizer.aspx?image=C:\Inetpub\wwwroot\Images\  house.jpg&thumb=C:\Inetpub\wwwroot\Images\house_thumb.jpg&width=500&height=-1

    the above will save the thumbnail as house_thumb.jpg in the
    same folder.

to use this in classic ASP code, use XMLHTTP component in
order to "communicate" with the aspx file. simply pass the
URL as demonstrated above:
Code:
<%
Dim strImageName, strThumbName, objXML
strImageName = "mypicture.jpg"
strThumbName = "mypicture_thumb.jpg"
Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
objXML.Open "GET", "http://localhost/ImageResizer.aspx?image=" & Server.MapPath(strImageName) & "&thumb=" & Server.MapPath(strThumbName) & "&width=500&height=-1", True
objXML.Send
Set objXML=Nothing
Response.Write("original: <img src=""" & strImageName & """ /><br />")
Response.Write("thumbnail: <img src=""" & strThumbName & """ /><br />")
%>



good luck and happy programming!
Attached Files
File Type: zip ImageResizer.zip (4.7 KB, 219 views)

Last edited by Shadow Wizard : February 5th, 2008 at 04:25 AM.

Reply With Quote
  #2  
Old October 3rd, 2006, 10:02 PM
baseballdude_'s Avatar
baseballdude_ baseballdude_ is offline
Expert Learner
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2005
Location: Wisconsin
Posts: 1,856 baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)  Folding Points: 22104 Folding Title: Starter FolderFolding Points: 22104 Folding Title: Starter Folder
Time spent in forums: 1 Week 5 Days 9 h 30 m 59 sec
Reputation Power: 59
Send a message via AIM to baseballdude_ Send a message via MSN to baseballdude_ Send a message via Yahoo to baseballdude_ Send a message via Google Talk to baseballdude_
Yahav, I looooooooooooooooooove you.

Did I mention that I love you Yahav?
Comments on this post
Shadow Wizard agrees: umm... I think so... :blush:

Reply With Quote
  #3  
Old October 3rd, 2006, 11:10 PM
baseballdude_'s Avatar
baseballdude_ baseballdude_ is offline
Expert Learner
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2005
Location: Wisconsin
Posts: 1,856 baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)  Folding Points: 22104 Folding Title: Starter FolderFolding Points: 22104 Folding Title: Starter Folder
Time spent in forums: 1 Week 5 Days 9 h 30 m 59 sec
Reputation Power: 59
Send a message via AIM to baseballdude_ Send a message via MSN to baseballdude_ Send a message via Yahoo to baseballdude_ Send a message via Google Talk to baseballdude_
** Disregard this...I just got it fixed! There was a permissions problem after all -- the internet guest account on this new server wasn't the default IUSR :\

I've combined your upload script with the resizer to create thumbnails of images when they are uploaded. The following script piece only uploads the original file and nothing more. I tested to see that paths are right...what am I doing wrong?
ASP Code:
Original - ASP Code
  1. If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
  2.     Dim objUpload
  3.     Set objUpload = New ShadowUpload
  4.     If objUpload.GetError <> "" Then
  5.         Response.Write("Sorry, could not upload: " & objUpload.GetError)
  6.     Else
  7.         Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
  8.         strDir = strPath & dir
  9.         For x = 0 To objUpload.FileCount-1
  10.             If (objUpload.File(x).ImageWidth < 1) Or (objUpload.File(x).ImageHeight < 1) Then
  11.                 Response.Write("Invalid file type!")
  12.                 Response.End()
  13.             Else
  14.                 Call objUpload.File(x).SaveToDisk(strDir, "")
  15.                 u_bound = u_bound + 1
  16.                 ReDim Preserve arrImages(u_bound)
  17.                 arrImages(u_bound) = objUpload.File(x).FileName
  18.                 strImageName = strDir & "\" & objUpload.File(x).FileName
  19.                 strThumbName = strDir & "\" & getFileName(objUpload.File(x).FileName)
  20.                 objXML.Open "GET", strPathToDir & "ImageResizer.aspx?image=" & strImageName & "&thumb=" & strThumbName & "&width=120&height=-1", True
  21.                 objXML.Send()
  22.             End If
  23.         Next
  24.         Set objXML = Nothing
  25.     End If
  26. End If

Last edited by baseballdude_ : October 3rd, 2006 at 11:22 PM.

Reply With Quote
  #4  
Old October 3rd, 2006, 11:50 PM
baseballdude_'s Avatar
baseballdude_ baseballdude_ is offline
Expert Learner
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2005
Location: Wisconsin
Posts: 1,856 baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)  Folding Points: 22104 Folding Title: Starter FolderFolding Points: 22104 Folding Title: Starter Folder
Time spent in forums: 1 Week 5 Days 9 h 30 m 59 sec
Reputation Power: 59
Send a message via AIM to baseballdude_ Send a message via MSN to baseballdude_ Send a message via Yahoo to baseballdude_ Send a message via Google Talk to baseballdude_
I actually am having the same problem again. The XMLHTTP doesn't seem to work right (even though it doesn't error) and doesn't create the thumbnail. I have this temporarily solved, having it create an iframe to be displayed, lol...but do you know what I'm doing wrong from the post above?

Reply With Quote
  #5  
Old October 4th, 2006, 01:08 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information.
 
Join Date: Sep 2004
Location: Israel
Posts: 26,621 Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)  Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 4 Days 13 h 47 m 29 sec
Reputation Power: 1441
debug the code by adding those lines:
Code:
Dim strURL,  strResult
strURL = strPathToDir & "ImageResizer.aspx?image=" & strImageName & "&thumb=" & strThumbName & "&width=120&height=-1"
Response.Write("URL: " & strURL & "<br />")
objXML.Open "GET", strURL, True
objXML.Send
strResult = objXML.ResponseText
Respose.Write("response: " & strResult & "<br />")

and let me know the result of the debugging.

Reply With Quote
  #6  
Old October 16th, 2006, 09:42 AM
petrusj petrusj is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 3 petrusj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 47 sec
Reputation Power: 0
Does it support only JPG? Tried with GIF images and it didn't create thumbnail.

Reply With Quote
  #7  
Old October 16th, 2006, 10:14 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information.
 
Join Date: Sep 2004
Location: Israel
Posts: 26,621 Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)  Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 4 Days 13 h 47 m 29 sec
Reputation Power: 1441
it may fail on certain images. attach the image here if possible and
I'll see for myself. did you try successfully with other images?

Reply With Quote
  #8  
Old October 16th, 2006, 12:20 PM
petrusj petrusj is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 3 petrusj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 47 sec
Reputation Power: 0
Quote:
Originally Posted by Shadow Wizard
it may fail on certain images. attach the image here if possible and
I'll see for myself. did you try successfully with other images?

Try it yourself with any image other than JPG. It works perfectly with JPG, but I had no luck with GIF or PNG.

Reply With Quote
  #9  
Old October 17th, 2006, 02:06 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information.
 
Join Date: Sep 2004
Location: Israel
Posts: 26,621 Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)  Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1Folding Points: 325693 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 4 Days 13 h 47 m 29 sec
Reputation Power: 1441
Quote:
Originally Posted by kaid
I use classic ASP and don't have ASP.NET
can I use this code ?
if the server you work with does not have .NET framework you
can't use my code, sorry.

Reply With Quote
  #10  
Old October 17th, 2006, 02:19 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information.
 
Join Date: Sep 2004
Location: Israel
Posts: 26,621 Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 7th Grade (Above 100000 Reputation Level)