REA_ANDREW
asked on
Resize Images
How do I resize images with ASP.NET 2.0 and using C#??
thanks in advance
Andrew
thanks in advance
Andrew
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also, you must modify this line, if you want to let the width be variable without limits:
Dim bmp As Bitmap = CreateThumbnail(Path, Size, Size)
replace it with:
Dim bmp As Bitmap = CreateThumbnail(Path, Size, sSize)
To give u an example of this, use the code below also:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim rLink = Request.QueryString("vLink ")
Dim rWidth = Request.QueryString("w")
Dim rHeight = Request.QueryString("h")
Dim sSize As String = rWidth
Dim Size As Integer = rHeight
========================== ========== =======
Now change the image tag to:
<img src="sizer.aspx?vLink=http://www.myDomain.com/img/myImage.jpg&w=500&h=300">
This will resize the image to 500 by 300.
regards,
KS
Dim bmp As Bitmap = CreateThumbnail(Path, Size, Size)
replace it with:
Dim bmp As Bitmap = CreateThumbnail(Path, Size, sSize)
To give u an example of this, use the code below also:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim rLink = Request.QueryString("vLink
Dim rWidth = Request.QueryString("w")
Dim rHeight = Request.QueryString("h")
Dim sSize As String = rWidth
Dim Size As Integer = rHeight
==========================
Now change the image tag to:
<img src="sizer.aspx?vLink=http://www.myDomain.com/img/myImage.jpg&w=500&h=300">
This will resize the image to 500 by 300.
regards,
KS
ASKER
When I pasted the code into. It gave me these errors in the error window
Error 1 Type 'Bitmap' is not defined. C:\Inetpub\wwwroot\frag\si zer.aspx.v b 46 134 C:\...\frag\
Error 2 Type 'Bitmap' is not defined. C:\Inetpub\wwwroot\frag\si zer.aspx.v b 49 30 C:\...\frag\
Error 3 Type 'Bitmap' is not defined. C:\Inetpub\wwwroot\frag\si zer.aspx.v b 82 26 C:\...\frag\
Error 4 Type 'Graphics' is not defined. C:\Inetpub\wwwroot\frag\si zer.aspx.v b 84 22 C:\...\frag\
Error 5 Name 'Brushes' is not declared. C:\Inetpub\wwwroot\frag\si zer.aspx.v b 86 29 C:\...\frag\
Error 6 End of statement expected. C:\Inetpub\wwwroot\frag\si zer.aspx.v b 99 64 C:\...\frag\
Error 7 Name 'rLink' is not declared. C:\Inetpub\wwwroot\frag\si zer.aspx.v b 110 70 C:\...\frag\
Error 8 Type 'Bitmap' is not defined. C:\Inetpub\wwwroot\frag\si zer.aspx.v b 114 20 C:\...\frag\
Error 1 Type 'Bitmap' is not defined. C:\Inetpub\wwwroot\frag\si
Error 2 Type 'Bitmap' is not defined. C:\Inetpub\wwwroot\frag\si
Error 3 Type 'Bitmap' is not defined. C:\Inetpub\wwwroot\frag\si
Error 4 Type 'Graphics' is not defined. C:\Inetpub\wwwroot\frag\si
Error 5 Name 'Brushes' is not declared. C:\Inetpub\wwwroot\frag\si
Error 6 End of statement expected. C:\Inetpub\wwwroot\frag\si
Error 7 Name 'rLink' is not declared. C:\Inetpub\wwwroot\frag\si
Error 8 Type 'Bitmap' is not defined. C:\Inetpub\wwwroot\frag\si
hi
this link has sample project what you want
http://www.codeproject.com/aspnet/pnguploader.asp
Thanks
this link has sample project what you want
http://www.codeproject.com/aspnet/pnguploader.asp
Thanks
Andrew,
You need to include the following lines at the very top:
Imports System.Drawing.Imaging
Imports System.Net
Imports System.IO
You need to include the following lines at the very top:
Imports System.Drawing.Imaging
Imports System.Net
Imports System.IO
ASKER
ok I have narrowed the rrors down to 2
Error 1 Type 'ImageFormat' is not defined. C:\Inetpub\wwwroot\frag\si zer.aspx.v b 50 29 C:\...\frag\
Error 2 Name 'ImageFormat' is not declared. C:\Inetpub\wwwroot\frag\si zer.aspx.v b 117 41 C:\...\frag\
I am designing with ASP.NET 2.0
Error 1 Type 'ImageFormat' is not defined. C:\Inetpub\wwwroot\frag\si
Error 2 Name 'ImageFormat' is not declared. C:\Inetpub\wwwroot\frag\si
I am designing with ASP.NET 2.0
ASKER
I have. but in asp.net 2.0 the first one is now
Imports System.Drawing
Imports System.Drawing
ASKER
I fixed it using this at the top
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Net
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Net
Imports System.IO
Yes, I just looked it up and saw that the namespaces had slightly been changed, so you had to include Drawing as well.
All the best.
All the best.
Following will help you.
True Image Resizing
http://aspnet.4guysfromrolla.com/articles/012203-1.aspx
Regards,
NetSwap