Last post Oct 13, 2011 01:18 AM by Shailen
Aug 11, 2002 06:29 AM|IliaT|LINK
Aug 20, 2002 10:45 PM|Tekmaven|LINK
Aug 21, 2002 12:15 AM|ASPSmith|LINK
Aug 23, 2002 11:51 PM|gbrown|LINK
Aug 24, 2002 02:36 AM|IliaT|LINK
Sep 06, 2002 08:40 AM|qwert231|LINK
Sep 06, 2002 03:51 PM|johndev|LINK
Sep 06, 2002 10:38 PM|IliaT|LINK
Nov 17, 2003 08:00 PM|SosaWISE|LINK
Dec 15, 2007 10:24 AM|prajeeshkkindia|LINK
Can anyone provide method/code to crope an image while uploading?
client side image compression
Jun 03, 2008 08:25 PM|yippanion|LINK
What's the difference between the GetThumbnailImage() method and just creating a new image from an old image passing it width/height?
It looks like the GetThumbnailImage loses more quality even if you keep it the same size than creating a whole new image of the same size. Anyone know what these two techniques are doing under the hood? Why don't they retain the same quality and resolution
if you're creating an image of the same size?
Here are my stats doing both:
The original .jpg is 80k at 400x500 (hor. res.=72, vert. res.=72)
When I use GetThumbnailImage() and pass it 400x500, the resulting file size is then 28k (hor. res.=282, vert. res.= 281) and real blurry.
When I create a new bitmap and save as Jpeg at 400x500, the resulting file size is then 38k (hor. res.=96, vert. res.= 96) and the quality is almost as good as the original.
Well, when I read up on this, GetThumbnailImage() method actually has a limitation in terms of size to resize to. I think this is around the 120px X 120px size. So if you pass it 400x500, it means the resizer is actually drawing the image smaller and then
stretching it out again which is why you are getting the blurry res. Resizing the Bitmap by using the save method doesnt do this which is why you get the same res.
Jul 22, 2008 11:49 PM|Carteja|LINK
This is how the vb code for the resize image
Public Sub ResizeFromStream(ByVal ImageSavePath As String, ByVal MaxSideSize As Integer, ByVal Buffer As System.IO.Stream)
Dim intNewWidth As Integer
Dim intNewHeight As Integer
Dim imgInput As System.Drawing.Image = System.Drawing.Image.FromStream(Buffer)
'Determine image format
Dim fmtImageFormat As ImageFormat = imgInput.RawFormat
'get image original width and height
Dim intOldWidth As Integer = imgInput.Width
Dim intOldHeight As Integer = imgInput.Height
'determine if landscape or portrait
Dim intMaxSide As Integer
If (intOldWidth >= intOldHeight) Then
intMaxSide = intOldWidth
intMaxSide = intOldHeight
If (intMaxSide > MaxSideSize) Then
'set new width and height
Dim dblCoef As Double = MaxSideSize / CDbl(intMaxSide)
intNewWidth = Convert.ToInt32(dblCoef * intOldWidth)
intNewHeight = Convert.ToInt32(dblCoef * intOldHeight)
intNewWidth = intOldWidth
intNewHeight = intOldHeight
'create new bitmap
Dim bmpResized As Drawing.Bitmap = New Drawing.Bitmap(imgInput, intNewWidth, intNewHeight)
'save bitmap to disk
'release used resources
Sep 04, 2008 04:13 PM|Carteja|LINK
Here is a great opens source tool that allows a user to actually resize his or her image and crop it to any size.
Its really good!
If you need a dll file for the vb version let me know, i re-did mine in VB.NET
Sep 23, 2008 02:48 PM|toekneeh|LINK
I downloaded the sample, and can't get it to work. When I click to upload the picture, the page just posts back to itself and I get a blank page. Have you been able to get this to work? I am using VisualStudio 2008, I tried with both the 2.0 and the
3.5 framework and it didn't make a difference.
Sep 24, 2008 11:18 AM|Carteja|LINK
Yes I did, However I re-did it in Vb.Net due to the fact that when tried to use the C# version I was getting a problem with the control it self.
If you would like the Vb.net version or the DLL file you can let me know and I will send it to your email.
Oct 27, 2008 12:15 AM|cutekids525|LINK
Hi... I have used your code..but i am getting the following error...
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+
Please suggest me...
Oct 27, 2008 10:57 AM|Carteja|LINK
I got the error when i didnt give the folder read and write permission to the ASP.NET user or the IIS user depending on your settings. Just give the user full control on the directory it is working in.
Aug 18, 2009 03:37 PM|Carteja|LINK
Make sure to give the folder the control perfoming its work on access to the ASP.NET user or if you are using the IIS_USR, make sure you give it full access.
Dec 21, 2009 12:38 PM|romah|LINK
I am trying to run this code from asp.net button click event. I got an exception error on this line.
It says "A generic error occurred in GDI+"
I have searched this error in forum and most of the post says "this is because of permission".
I am using administrator and I didn't see any restriction to copy and create any files in c:\temp\
Other post says "Need to put GC.Collect()". I also added that method but again the same error.
Why is that problem occurred?
Dec 22, 2009 08:56 AM|Pankaj Rai|LINK
Please refer this link .....
Feb 24, 2010 01:24 AM|SalMan_pc|LINK
How Can I call This Method For Upload a image
i have a folder (Products) ,Iwant to upload images to this folder in same size
pls replay me..
Mar 02, 2010 04:20 PM|muybn|LINK
This worked for me (in VB):
Partial Class [yourClass]
Sub ImageResize(ByVal strDest As String)
Const intMaxWidth As Integer = 300 'max width
Const intMaxHgt As Integer = 300 'max height
Dim intNewWidth, intNewHgt As Integer ' new width/height
Dim sglSize As Single 'temp variable used when calculating new size
Dim imgOriginal As Image 'holds the original image
Dim ful As FileUpload = Util.FindChild(Me, "Upload")
If ful IsNot Nothing Then
imgOriginal = Image.FromStream(ful.FileContent)
If (imgOriginal.Width / intMaxWidth) > (imgOriginal.Height / intMaxHgt) Then
sglSize = imgOriginal.Width
intNewWidth = intMaxWidth
intNewHgt = imgOriginal.Height * (intMaxWidth / sglSize)
If intNewHgt > intMaxHgt Then
intNewWidth = intNewWidth * (intMaxHgt / intNewHgt)
intNewHgt = intMaxHgt
sglSize = imgOriginal.Height
intNewHgt = intMaxHgt
intNewWidth = imgOriginal.Width * (intMaxHgt / sglSize)
If intNewWidth > intMaxWidth Then
intNewHgt = intNewHgt * (intMaxWidth / intNewWidth)
intNewWidth = intMaxWidth
'Create a graphics object
Dim imgOutput As New Bitmap(intNewWidth, intNewHgt)
imgOutput = imgOriginal.GetThumbnailImage(intNewWidth, intNewHgt, Nothing, IntPtr.Zero)
Dim gr_dest As Graphics = Graphics.FromImage(imgOutput)
'Re-draw the image to the specified height and width
gr_dest.DrawImage(imgOriginal, 0, 0, imgOutput.Width, imgOutput.Height)
Jul 10, 2010 01:40 AM|anishbhagwat80|LINK
Thanks for Code. This code is working fine in local host. But when i put it on the IIS (Shared hosting) then it gives error near bmpResized.Save(ImageSavePath, fmtImageFormat). I tried all the ways Server.MapPath...) , System.Web.HttpContext.Current.Request.PhysicalApplicationPath,
I tried all the possible ways. But same error.
Please help me.
Nov 23, 2010 07:30 AM|anil12398|LINK
Can u please mail me the Vb.Net code and dll generated in Vb.Net Version at email@example.com or firstname.lastname@example.org. I would be very thankful to you.
Nov 23, 2010 11:58 PM|anil12398|LINK
Please provide me Vb.net version and dll file at anil12398 of gmail dot com. I would be very thankful to you.
Dec 23, 2010 05:46 AM|kengkit|LINK
may i know what's Util.FindChild(Me, "Upload")
Dec 24, 2010 04:07 AM|waqar-ahmad|LINK
You check this link. I think it might be helpful in your case. This code work for me perfect.
Jan 10, 2011 04:10 AM|inzamam|LINK
if you want to resize image than using asp,net-2.0(vb)
more about how to resize image , i will you suggest you to visit the below link
please visit the link, here you can know about resizing image.
thank you very much.
May 02, 2011 04:04 PM|graphic-design-software|LINK
Is the above software code fast for resizing large photos? I need the fastest possible function for my online graphic design software.
May 03, 2011 10:13 AM|Abhimanyu Kumar Vatsa|LINK
the best article to learn this
May 31, 2011 11:00 AMemail@example.com|LINK
This is a much simpler explanation, and includes a sample project:
Combining jCrop and server-side image resizing in 11 lines
The sample project
The basic demo
The advanced demo
Oct 13, 2011 01:18 AM|Shailen|LINK
Hi Here is the code for cropping the image in C#
The method takes two objects - the image to crop (System.Drawing.Image) and the rectangle to crop out (System.Drawing.Rectangle). The next thing done is to create a Bitmap (System.Drawing.Bitmap) of the image. The only thing left is to crop the image. This
is done by cloning the original image but only taking a rectangle of the original.
client side image compression