Print Page | Close Window

thumbnail resize URI format

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=11286
Printed Date: 28 March 2026 at 4:07am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: thumbnail resize URI format
Posted By: Badaboem
Subject: thumbnail resize URI format
Date 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.



Replies:
Posted By: dpyers
Date 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.


Posted By: Badaboem
Date 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?


Posted By: Badaboem
Date Posted: 25 July 2004 at 4:06pm
I'm beginning to suspect ''FromFile" doesn't support uri formats. 


Posted By: dpyers
Date Posted: 25 July 2004 at 5:39pm

Here's an article on image resizing that may help.
http://aspnet.4guysfromrolla.com/articles/012203-1.aspx - http://aspnet.4guysfromrolla.com/articles/012203-1.aspx



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Badaboem
Date 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.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net