473,799 Members | 2,997 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Thumbnail Generation

mo
Hi,
I have the following code to create a thumbnail from the input stream

System.Drawing. Image source;
source=System.D rawing.Image.Fr omStream(new
System.IO.Memor yStream(myData) );
System.Drawing. Image image = source.GetThumb nailImage
150,150,null,In tPtr.Zero);
MemoryStream ms = new MemoryStream();
ImageFormat thisformat=imag e.RawFormat;
Bitmap imagebitmap = new Bitmap(image,15 0,150);
imagebitmap.Sav e(ms,thisformat );
ms.Seek(0,SeekO rigin.Begin);
byte[] SmallmyData = new byte[ms.Length];
FileStream newFile = new FileStream(strP ath, FileMode.Create );
newFile.Write(B uffer, 0, SmallmyData.Len gth);
newFile.Close() ;

Two problems I have
1) imagebitmap.Sav e(ms,thisformat ); line faults and cannot find the
value for thisformat (It works if I replace it with ImageFormat.Jpe g)
2) the file that gets created is corrupt.

ANy help is greatly appreciated.

Thanks,
Mo
Nov 18 '05 #1
1 1296

Try this code:

http://west-wind.com/weblog/posts/283.aspx

and

http://west-wind.com/weblog/posts/626.aspx
In addition to working <g>, the above code doesn't use GetThumbnailIma ge
which generally does a pretty poor job of creating thumbnails. The second
post talks about adding a switch for the InterpolationMo de to further
enhance image quality of a resized image.

Regards,

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
http://www.west-wind.com/wwThreads/
----------------------------------
Making waves on the Web
"mo" <le******@yahoo .com> wrote in message
news:c3******** *************** ***@posting.goo gle.com...
Hi,
I have the following code to create a thumbnail from the input stream

System.Drawing. Image source;
source=System.D rawing.Image.Fr omStream(new
System.IO.Memor yStream(myData) );
System.Drawing. Image image = source.GetThumb nailImage
150,150,null,In tPtr.Zero);
MemoryStream ms = new MemoryStream();
ImageFormat thisformat=imag e.RawFormat;
Bitmap imagebitmap = new Bitmap(image,15 0,150);
imagebitmap.Sav e(ms,thisformat );
ms.Seek(0,SeekO rigin.Begin);
byte[] SmallmyData = new byte[ms.Length];
FileStream newFile = new FileStream(strP ath, FileMode.Create );
newFile.Write(B uffer, 0, SmallmyData.Len gth);
newFile.Close() ;

Two problems I have
1) imagebitmap.Sav e(ms,thisformat ); line faults and cannot find the
value for thisformat (It works if I replace it with ImageFormat.Jpe g)
2) the file that gets created is corrupt.

ANy help is greatly appreciated.

Thanks,
Mo

Nov 18 '05 #2

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

Similar topics

5
8252
by: Simon Wigzell | last post by:
I need a simple function to generate and save a thumbnail from a picture. It would require : Source Picture Fileame Thumbnail Height and Width Thumbnail Filename There are many pay programs available but they do far more than I require and I want the code to be built in to my code, not operate as a separate program. Any ideas? The browser knows how to resize pictures easily enough,
0
5614
by: Mike | last post by:
Sites using thumbnail preview for world wide web file navigation and searching. Below are list of sites that are either researching or providing thumbnail preview images for online web documents. Thumbnail previews are useful for web site navigation particularly in search engines and directories such as Google, Altavista and Yahoo. The preview images provide a portion of the content of the electronic file to aid in navigation.
0
1844
by: Cecil Windham | last post by:
I'm enabling users to rotate photos and generate thumbnails. I have discovered that if, after a user rotates a photo 180 degrees, then generates a thumbnail, that the resulting thumbnail appears unrotated (i.e., in original position, or rotated zero degrees). Why is this? (and yes, I have verified that the "original" from which the thumbnail is generated has, in fact, been rotated 180 degrees prior to generating the thumbnail).
1
1153
by: db | last post by:
In explorer you can change the view setting to thumbnails, and you get thumbnails even from movies. I want to do the same from asp.net. I want to create 'on the fly' thumbnails from some mpg movies, but I don't know if that's possible from asp.net. Who can help me with this?
1
3243
by: Xah Lee | last post by:
The following is a program to generate thumbnail images for a website. Useful, if you want to do that. It is used to generate the thumbnails for my “Banners, Damsels, and Mores” project gallery. ( http://xahlee.org/Periodic_dosage_dir/lanci/lanci.html ) Comments and versions in other lang welcome. Xah
8
20371
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1: Start with original thumbnails & two empty sub directories STEP 2: Create smaller versions of the originals for one sub directory STEP 3: Create thumbnail version of the originals the other sub directory STEP 4: Create an index.html pointing to the...
4
6569
by: dean.greg | last post by:
Im looking for a way to generate thumbnails from an image as fast as possible. Currently I'm using GDI+ however going from 1024x768 to 100x100 takes too long. I'd imagine the whole process can be optimized by using hardware acceleration (ie DirectX), however I am not all that familar with the DirectX API. What I'm looking for is some direction, or even some sample/psuedo code, that might point me in the right direction. If not...
7
2355
by: oscartheduck | last post by:
Hi folks, I'm trying to alter a program I posted about a few days ago. It creates thumbnail images from master images. Nice and simple. To make sure I can match all variations in spelling of jpeg, and different cases, I'm using regular expressions. The code is currently:
2
1208
AaronL
by: AaronL | last post by:
Hello, I would like to have thumbnails generated automatically from images uploaded from my image upload system. Can anyone tell me what I need to do? Here is the link to my php info page, I'm not sure if gd is enabled or not. I may have to go with a freeware cgi script or something www.lambertsoftware.com/ecomm/phpinfo.php Thanks!
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10252
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
10231
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,...
1
7565
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
6805
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
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
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.