Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - thumbnail resize URI format
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

thumbnail resize URI format

 Post Reply Post Reply
Author
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2004 at 4:06pm
I'm beginning to suspect ''FromFile" doesn't support uri formats. 
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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


Lead me not into temptation... I know the short cut, follow me.
Back to Top
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.