
March 31st, 2003, 05:10 PM
|
|
Registered User
|
|
Join Date: Mar 2003
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Trying to resize stored images to specified size.
Trying to resize stored images to specified size and then overwrite original file, whenver file is now bigger or smaller.<br><br>I call this function resize, passing to it two variables. The first is the full file name(m = c:inetpubwwwrootestateimages1 lah.jpg) and the second is just a count. For some reason all repsonse.writes return the correct files name but when I actually save the new resized image, it gives me a "A generic error occurred in GDI+." error. on the save line. Please someone help me!! I have already enabled access to this folder so it is not that. HELP ME PLEASE!!!<br><br>Sub resize(m,c)<br> Dim desiredSize, newHeight, newWidth as Integer<br> Dim x as string<br> x = m<br> Dim inputFile as new FileInfo(x)<br> Dim inputImage as System.Drawing.Image<br> inputImage = System.Drawing.Image.FromFile(x)<br> Dim outputImage as System.Drawing.Image<br> Dim savefile as string<br> desiredSize = 100<br> <br> Try<br> ' find out how the picture is oriented<br> if inputImage.Width > inputImage.Height ' landscape-layout<br> ' calculate new height<br> newHeight = ((desiredSize * 1.0 / inputImage.Width) * inputImage.Height)<br> newWidth = desiredSize<br> else ' portrait-layout<br> newHeight = desiredSize<br> ' calculate new width<br> newWidth = ((desiredSize * 1.0/ inputImage.Height) * inputImage.Width)<br> end if<br><br> ' resize picture<br> outputImage = new Bitmap(inputImage, newWidth, newHeight)<br> Catch Exp as exception<br> outputImage = inputImage<br> End Try<br><br> savefile = inputFile.DirectoryName & """ & Path.GetFileName(x)<br> outputImage.Save(savefile,inputImage.rawformat)<br> ListFiles.items.insert (c, new ListItem(x,x)) <br>End Sub<!-- Edit --><p><i>Last Edited : 3/31/2003 2:34:12 PM GMT</i></p>
|