473,758 Members | 2,340 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resize Image!!

Hi all,

I am trying resize an image using the following code.

//resize image
System.Drawing. Image ImageUpload =
System.Drawing. Image.FromFile( String.Concat(S erver.MapPath(F ilePath),ImageN ame));

// create the actual thumbnail image
System.Drawing. Image ThumbnailImage =
ImageUpload.Get ThumbnailImage( 250,ImageUpload .Height * 250 /
ImageUpload.Wid th, new
System.Drawing. Image.GetThumbn ailImageAbort(T humbnailCallbac k),
IntPtr.Zero);
ThumbnailImage. Save(ImageName) ); //ie: test.jpg

However i keep getting this error:
Exception Details: System.Runtime. InteropServices .ExternalExcept ion: A
generic error occurred in GDI+.

Any one have any ideas?
Cheers,
Adam
Apr 7 '06 #1
2 1651
DWS
Adam
What line is error?

Thanks
DWS
"Adam J Knight" wrote:
Hi all,

I am trying resize an image using the following code.

//resize image
System.Drawing. Image ImageUpload =
System.Drawing. Image.FromFile( String.Concat(S erver.MapPath(F ilePath),ImageN ame));

// create the actual thumbnail image
System.Drawing. Image ThumbnailImage =
ImageUpload.Get ThumbnailImage( 250,ImageUpload .Height * 250 /
ImageUpload.Wid th, new
System.Drawing. Image.GetThumbn ailImageAbort(T humbnailCallbac k),
IntPtr.Zero);
ThumbnailImage. Save(ImageName) ); //ie: test.jpg

However i keep getting this error:
Exception Details: System.Runtime. InteropServices .ExternalExcept ion: A
generic error occurred in GDI+.

Any one have any ideas?
Cheers,
Adam

Apr 7 '06 #2
Take a look at this...
http://www.howtodothings.com/compute...humbnails.html

I seem to remember having to process it from memory. If I recall correctly
the GDI+ error only occurred if I tried to process an image from disk that I
had only just saved, which is why I decided to process from memory instead.

Pete
Apr 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
14472
by: Julia Briggs | last post by:
I am struggling to create a PHP function that would take a specified image (JPG, GIF or PNG) from a link, and resize it down to a thumbnail so it will always fit in a 200x250 space. I am hoping not to have it inserted or read from a database to do this function. Can it be done & someone please help me?
1
4411
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail image in a byte of what is in the database. I also want to be able to display this image in an <asp:image></asp:image> control. Is there any way to do this? Most of the examples that I've seen have used
1
1902
by: David | last post by:
Hello. How can I resize image in Bitmap object?
3
2832
by: DichkoSoft | last post by:
Dear All I don't know haw i resize inage in VB.NET I want load image with size 800x600 then rezize it to 80x60 pixels and save to a file. -- DichkoSoft
1
3778
by: Arjen | last post by:
Hi, I want to resize an image on my server. I tried a lot of samples... but all the time it does resize and saves the images but I can not view the image insize a webbrowser. With an imageviewer (desktop application) I can view the image. I believe there is something wrong with the maximum colors... This is what I have now... Image originalBitmap = Image.FromFile("C:\temp\image.jpg", true);
6
4533
by: Bob Bedford | last post by:
Hi all, I've a classic upload form where people may select images on their computer to send on my website. Since this is done by people not very confortable with computers, some sent pictures are very huge (3MB) and I do resize them anyway since I only allow 500px wide pictures. Instead of letting people upload the 3MB file then resize it on the server,
6
3322
by: Bob Bedford | last post by:
Hi all, I've to resize uploaded images with the "imagecopyresampled" but when I've images quite large (common those days) I reach the 16mb limits of the ISP. How can I fix this ? I absolutely need to resize such images. Bob
3
14123
by: Danny Ni | last post by:
Hi, I am looking for a way to display images with different aspect ratio into frames with fixed width and height, the problem is some images will look distorted if they are forced into fixed frame due to differnt aspect ratio. Some graphic designer suggests me to keep the aspect ratio of the original graphic and pad the graphic with empty space to fit into the frame. One example, the fixed frame is 100x60 and the image is 120x120, I...
3
2558
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
how can i reesize an image so its quallity will stay the same as the original 1? thnaks in advance peleg
0
9492
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9908
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9740
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8744
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7287
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5332
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2702
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.