.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 31st, 2003, 05:10 PM
Little20 Little20 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 1 Little20 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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>

Reply With Quote
  #2  
Old April 14th, 2003, 12:27 PM
bkalicharan bkalicharan is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 51 bkalicharan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 42 m 59 sec
Reputation Power: 6
Hi Little,<br><br>It is a very good code...<br>I found the error when I tested this program in my system.<br>U r trying to save the file with same file name which is being used for the new image.<br>Try out with other name it is working fine.<br>Check it.<br><br>First u save it with some other name and then delete the original file and rename the new image with original name.<br>b4 that dispose all the objects used which reference to the original image.<br><br>Kalicharan

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > Trying to resize stored images to specified size.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT