473,573 Members | 2,889 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

thumbnail has poor quality

I'm creating a thumbnail from an image saved in a db. If I write the
data directly to the stream, the image shows up perfectly.

Response.Clear( );
Response.Conten tType = myImage.Content Type;
Response.Binary Write( myImage.File );

But if i try and make a thumb, the image is distorted.

MemoryStream stream = new MemoryStream( myImage.File );
Bitmap bitmap = new Bitmap( stream );
Image image = bitmap.GetThumb nailImage( 100, 100, null, IntPtr.Zero );
image.Save( Response.Output Stream, bitmap.RawForma t );

Is there a way to make this clear?

Aug 9 '06 #1
5 2418
Hi,

Narshe wrote:
I'm creating a thumbnail from an image saved in a db. If I write the
data directly to the stream, the image shows up perfectly.

Response.Clear( );
Response.Conten tType = myImage.Content Type;
Response.Binary Write( myImage.File );

But if i try and make a thumb, the image is distorted.

MemoryStream stream = new MemoryStream( myImage.File );
Bitmap bitmap = new Bitmap( stream );
Image image = bitmap.GetThumb nailImage( 100, 100, null, IntPtr.Zero );
image.Save( Response.Output Stream, bitmap.RawForma t );

Is there a way to make this clear?

I think that what you mean with "distorted" is that you create
thumbnails having a size of 100*100 pixels, regardless of the original
size. If you want to keep the original proportions, you must calculate
the corresponding width, respectively height:

Bitmap bmpOriginal = new Bitmap( strPath );

int iNewHeight = m_iMaxSize;
float fRate = (float) iNewHeight / (float) bmpOriginal.Hei ght;
int iNewWidth = (int) Math.Round( (float) bmpOriginal.Wid th * fRate );
if ( iNewWidth m_iMaxSize )
{
iNewWidth = m_iMaxSize;
fRate = (float) iNewWidth / (float) bmpOriginal.Wid th;
iNewHeight = (int) Math.Round( (float) bmpOriginal.Hei ght * fRate );
}

Bitmap bmpNew = new Bitmap( bmpOriginal, iNewWidth, iNewHeight );
bmpNew.Save( Response.Output Stream, bmpOriginal.Raw Format );

In the code above, I have m_iMaxSize set by the user (in your case 100).

I use this way (more or less) to create thumbnails dynamically in this page:
http://www.galasoft-lb.ch/pictures/welcome.aspx

It's true that the thumbnails look less clear than if produced using a
graphics application (I use SuperJpg when I want to make "static"
thumbnails). However, it's not that bad I think.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 11 '06 #2
Laurent Bugnion wrote:
I think that what you mean with "distorted" is that you create
thumbnails having a size of 100*100 pixels, regardless of the original
size. If you want to keep the original proportions, you must calculate
the corresponding width, respectively height:
I actually have it doing something like this already, I just whipped up
sample code for an example.

The image is not clear. It's fuzzy and poor quality. I'll give your
method a try and see if that helps.

Aug 11 '06 #3
Hi,

Narshe wrote:
Laurent Bugnion wrote:
>>I think that what you mean with "distorted" is that you create
thumbnails having a size of 100*100 pixels, regardless of the original
size. If you want to keep the original proportions, you must calculate
the corresponding width, respectively height:


I actually have it doing something like this already, I just whipped up
sample code for an example.

The image is not clear. It's fuzzy and poor quality. I'll give your
method a try and see if that helps.
As I said, the method of creating thumbnails programatically produces
thumbnails with lesser quality than dedicated programs. Check the page I
gave you to see if the quality is any better. The original images are
640*480 or 480*640, and the thumbnails go down to 120 pixels.

http://www.galasoft-lb.ch/pictures/index.html

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 11 '06 #4

Laurent Bugnion wrote:
As I said, the method of creating thumbnails programatically produces
thumbnails with lesser quality than dedicated programs. Check the page I
gave you to see if the quality is any better. The original images are
640*480 or 480*640, and the thumbnails go down to 120 pixels.
Yes, they are a lot better. I used the google logo off their home page,
and brought the size down to 100x40 (iirc), and the image looks like it
is made up of a bunch of dots, like a news paper.

I haven't had a chance to try your method, been in a meeting, but I'll
let you know.

Thanks.

Aug 11 '06 #5
I tried your method and it still ended up fuzzy. Here's the pic
http://www.yousendit.com/tr*********...****@gmail.com

-Josh

Narshe wrote:
Laurent Bugnion wrote:
As I said, the method of creating thumbnails programatically produces
thumbnails with lesser quality than dedicated programs. Check the page I
gave you to see if the quality is any better. The original images are
640*480 or 480*640, and the thumbnails go down to 120 pixels.

Yes, they are a lot better. I used the google logo off their home page,
and brought the size down to 100x40 (iirc), and the image looks like it
is made up of a bunch of dots, like a news paper.

I haven't had a chance to try your method, been in a meeting, but I'll
let you know.

Thanks.
Aug 11 '06 #6

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

Similar topics

6
2480
by: Chris D | last post by:
Hi, I have an application where a user uploads an image and I create two thumbnails. One a small image and the second is a larger image but still smaller then the original. I store these in SQL 2000 server. The quality of the small thumbnail is ok, but the quality of the larger image is terrible. I tried both Jpeg and Gif formats and...
6
1735
by: Trint Smith | last post by:
How can I show image thumbnail?? thanks, Trint ..Net programmer trintsmith@hotmail.com *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
1
1289
by: mo | last post by:
Hi, I have the following code to create a thumbnail from the input stream System.Drawing.Image source; source=System.Drawing.Image.FromStream(new System.IO.MemoryStream(myData)); System.Drawing.Image image = source.GetThumbnailImage 150,150,null,IntPtr.Zero); MemoryStream ms = new MemoryStream(); ImageFormat thisformat=image.RawFormat;
4
1988
by: Øyvind Isaksen | last post by:
Hello! Does anyone know about an ASP.NET thumbnail script that generate thumbnail with MAX quality? Have tested some scripts, but the thumbnail is not getting as good quality as I need. This is the best result I have got so far: Original picture: http://www.kromogkubikk.no/custom/artimgs/bakgard.jpg Thumb, 128px:
1
1715
by: Cédric | last post by:
Hello, Wanting to create a thumbnail of an image, i'm using the following piece of code : Public Sub Reduction(ByVal Source As String, ByVal Destination As String, ByVal TailleX As String, ByVal TailleY As String, ByVal Resolution As Integer, ByVal Fond As Boolean, ByVal ConserverRatio As Boolean, ByVal PixelFormat As...
1
4979
by: Summercoolness | last post by:
In PIL, since thumbnail() first makes a draft copy of the image, and then resize it, so thumbnail() can run a lot faster than resize() because draft() seems a lot faster when resizing from very big images to small images... (such as the original image is 3000 x 2000, and it can make a draft really quickly to 375 x 250, and then resize to, say...
0
2518
by: sakurasyi | last post by:
hai guys... can someone solve my problems? i'm doing a thumbnail program. But, i have some problems. 1. The thumbnail image become black (cannot see anything) 2. Can anyone know how to get the size (height and width) of the original image? this is my code: Image image = Toolkit.getDefaultToolkit().getImage(namePath); MediaTracker...
8
20340
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...
15
13202
tlhintoq
by: tlhintoq | last post by:
I'd like to think I can work out most issues, but this one is kicking my butt. What's worse, is that I know I can't be the first guy to want to add a thumbnail to jpg that doesn't already have one. I see it in plenty of other applications. Yet I can't seem to make it work despite being so very close. I know the problem has to be in how I am...
0
8031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8204
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...
1
7795
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...
0
8073
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...
0
6424
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...
1
5600
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...
0
5294
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...
1
1309
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1044
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...

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.