| Author |
Topic Search Topic Options
|
Badaboem
Senior Member
Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
|
Post Options
Thanks(0)
Quote Reply
Topic: thumbnail resize URI format Posted: 25 July 2004 at 3:19pm |
Is it impossible to use URI formats with asp.net image resizing?
I'm trying to adjust a script that is able to resize images on my local
server, but once adjusted to use http:// or www. etc. it gives the
following error:
URI formats not supported
What is causing this issue, and is there a way to work around this issue?
Here's the script. I deleted the parts in red for it to accept http or www links (or so i hoped)
<%@ Import Namespace=System.Drawing %>
<%@ Import Namespace=System %>
<%@ Import Namespace=System.Web %>
<html>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
' Dim all Variables
Dim OrginalImg, Thumb As System.Drawing.Image
Dim Rootpath, FileName As String
Dim imgHeight, imgWidth, maxWidth, MaxHeight As Integer
Dim inp As New IntPtr()
' Get width using QueryString.
If Request.QueryString("width") = Nothing Then
maxWidth = orginalimg.Width
ElseIf Request.QueryString("width") = 0 Then
maxWidth = 180
Else
maxWidth = Request.QueryString("width")
End If
' Get height using QueryString.
If Request.QueryString("height") = Nothing Then
MaxHeight = orginalimg.Height
ElseIf Request.QueryString("height") = 0 Then
MaxHeight = 20
Else
MaxHeight = Request.QueryString("height")
End If
' Get Root Application Folder
rootpath = Server.MapPath("/")
' Get filename
FileName = rootpath & Request.QueryString("FileName")
' Attempt to populate the original image object
Try
orginalimg = orginalimg.FromFile(FileName)
' Get the current Height and width of the image
imgHeight = orginalimg.Height
imgWidth = orginalimg.Width
' Check to see if the image even needs scaled
If imgWidth > maxWidth Or imgHeight > MaxHeight Then
'Determine what dimension is off by more
Dim deltaWidth As Integer = 1
Dim deltaHeight As Integer = 2
Dim scaleFactor As Double
If deltaHeight > deltaWidth Then
' Use the Height to set the scale factor
scaleFactor = MaxHeight / imgHeight
Else
' Use the Width to set the scale factor
scaleFactor = maxWidth / imgWidth
End If
' Set the new Scaled the image Size
imgWidth *= scaleFactor
imgHeight *= scaleFactor
End If
' If the population fails get error.gif
Catch
orginalimg = orginalimg.FromFile(rootpath & "error.gif")
End Try
' set the thumbnail width and height by the new correct scale
thumb = orginalimg.GetThumbnailImage(imgWidth, imgHeight, Nothing, inp)
'Sending Response JPEG type to the browser.
Response.ContentType = "image/jpeg"
thumb.Save(Response.OutputStream, Imaging.ImageFormat.Jpeg)
'Disposing the objects.
orginalimg.Dispose()
thumb.Dispose()
End Sub
</script>
</html>
|
Thanks for your help.
|
 |
dpyers
Senior Member
Joined: 12 May 2003
Status: Offline
Points: 3937
|
Post Options
Thanks(0)
Quote Reply
Posted: 25 July 2004 at 3:48pm |
URI = URL (URI - Universal Resource Indicator is the proper name for what most people call a URL). Basically, the message indicates a badly formed URL.
Do a response.write on Server.MapParh("/") I don't think it contains what you think it does.
|
Lead me not into temptation... I know the short cut, follow me.
|
 |
Badaboem
Senior Member
Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
|
Post Options
Thanks(0)
Quote Reply
Posted: 25 July 2004 at 3:56pm |
|
i have deleted the red parts as stated before, so the response.write should be done on filename in this case.
Server.MapPAth is not used anymore because i want it to link to external images instead of images on my own server.
"Filename" does return the proper url:
http://129.125.101.174/c4dportal2/uploads/telnoiadmin/ downloads/2004-07-05_000346_nprsetup.jpg
Could it be that urls are simply not supported by image resizing in asp.net?
|
 |
Badaboem
Senior Member
Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
|
Post Options
Thanks(0)
Quote Reply
Posted: 25 July 2004 at 4:06pm |
|
I'm beginning to suspect ''FromFile" doesn't support uri formats.
|
 |
dpyers
Senior Member
Joined: 12 May 2003
Status: Offline
Points: 3937
|
Post Options
Thanks(0)
Quote Reply
Posted: 25 July 2004 at 5:39pm |
|
|
Lead me not into temptation... I know the short cut, follow me.
|
 |
Badaboem
Senior Member
Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 July 2004 at 4:08pm |
|
Thanks for that link, but it discusses the same old script in a somewhat different form.
I've searched google, several asp.net forums and nothing came up with
an answer as to if it's possible to use system draw on remote images.
If anybody knows (an alternative), please do let me know.
|
 |