| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
||||
|
||||
|
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:
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! ![]() Last edited by Shadow Wizard : February 5th, 2008 at 04:25 AM. |
|
#2
|
||||
|
||||
|
Yahav, I looooooooooooooooooove you.
Did I mention that I love you Yahav?
__________________
www.xoise.com - www.ourfreegames.com - www.playtouchgames.com - www.randomtools.net - www.xenocide-rpg.com |
|
#3
|
|||||
|
|||||
|
** 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:
Last edited by baseballdude_ : October 3rd, 2006 at 11:22 PM. |
|
#4
|
||||
|
||||
|
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?
|
|
#5
|
||||
|
||||
|
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. |
|
#6
|
|||
|
|||
|
Does it support only JPG? Tried with GIF images and it didn't create thumbnail.
|
|
#7
|
||||
|
||||
|
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? |
|
#8
|
|||
|
|||
|
Quote:
Try it yourself with any image other than JPG. It works perfectly with JPG, but I had no luck with GIF or PNG. |
|
#9
|
||||
|
||||
|
Quote:
can't use my code, sorry. |
|
#10
|
||||
|