Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Graphics and resizing images better than Image.GetThumbnailImage quality

78 views
Skip to first unread message

Roger

unread,
Jul 18, 2002, 10:40:53 PM7/18/02
to
I want to take a 1600x1200 jpeg and resize it to a image that is 160x120.
But, I want the resulting image to be a high quality image. Is there
someting else you can do with Image.GetThumbnailImage that will have it
create a higher quality image? I have a 900k image that when fed through
Image.GetThumbnailImage gives me a little 4k file (fast and small file size,
but looks terrible). When I go into Adobe Photoshop, resize to 160x120, and
play with the JPG output quality, I get varying sizes from 12 to 39k. The
lowest acceptable quality for what I want comes out to arond 33k.

I have also played around with System.Drawing.Graphics. Can anyone tell me
the optimum settings to get the best looking image with these?

With objGraphics
.CompositingMode = Drawing2D.CompositingMode.SourceOver
.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
.InterpolationMode = Drawing2D.InterpolationMode.High
.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
.DrawImage(objNewImage, 0, 0, 160, 120))
.Dispose()
End With
objImageBlank.Save(strNewFileName, System.Drawing.Imaging.ImageFormat.Jpeg)
objNewImage.Dispose()

Does the order matter? Also, what about these;

Graphics.TranslateClip
Graphics.ScaleTransform

They did some strange things, but I could not get the output I was looking
for. Any other suggestions would be appreciated.

Thanks,
Roger

Jeff Rhodes

unread,
Jul 19, 2002, 9:40:42 AM7/19/02
to
Hi Roger,

Eric Gunnerson posted the following in response to one of my posts in
another group, which could explain the image quality problem you are seeing:

One quick note on GetThumbnailImage(). If your picture comes from a digital
camera, it may have an embedded thumbnail. If it does, GDI+ will take that
thumbnail and resize it to the size you ask for rather than create a new
one. If the size you want is bigger, it looks pretty bad.

HTH,

--
Jeff Rhodes
Author of "VBTrain.Net: Creating Computer and Web Based Training with Visual
Basic® .NET"
www.vbtrain.net
Home of the Shape and Graphical Text controls

"Roger" <roger...@hotmail.com> wrote in message
news:uHNmk2sLCHA.2452@tkmsftngp08...

Greg Binkerd [MS]

unread,
Jul 19, 2002, 10:51:06 AM7/19/02
to
Hi, Roger.

You might want to do the scaling with Graphics.DrawImage and specify
"HighQualityBicubic" for the Interpolation Mode. Draw the image in a
"memory" Graphics object. Set the Interpolation Mode to HighQualityBicubic
before calling the Graphics.DrawImage method:

e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;


Thanks,
-Greg
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.


--------------------
| From: "Roger" <roger...@hotmail.com>
| Subject: Graphics and resizing images better than Image.GetThumbnailImage
quality
| Date: Thu, 18 Jul 2002 21:40:53 -0500
| Lines: 39
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <uHNmk2sLCHA.2452@tkmsftngp08>
| Newsgroups: microsoft.public.dotnet.framework.drawing
| NNTP-Posting-Host: 12.238.222.48
| Path: cpmsftngxa08!tkmsftngp01!tkmsftngp08
| Xref: cpmsftngxa08 microsoft.public.dotnet.framework.drawing:2505
| X-Tomcat-NG: microsoft.public.dotnet.framework.drawing

Roger

unread,
Jul 19, 2002, 8:48:03 PM7/19/02
to
Yes, that is better quality, and I tested that along with a couple of other
settings. Still, the quality that is produces is pretty low. It produces a
image that is 5k (160x120 pixels). A full res image should be at around 35k
or 40k at 160x120 (at least for the jpeg I am testing with). I need a
solution that will keep the high quality. I know there are apps out there
that do this, but I am not sure if I can get there with
System.Drawing.Graphics. What other options are there with .net?

Thanks,
Roger

"Greg Binkerd [MS]" <Gr...@online.microsoft.com> wrote in message
news:WkCZYOzLCHA.3204@cpmsftngxa07...

Greg Binkerd [MS]

unread,
Jul 22, 2002, 12:01:04 PM7/22/02
to
Hi, Roger.

The following articles may help:

INFO: Determine the JPEG Quality Factor by Using Visual C# .NET
ID: Q324790

INFO: Determine JPEG Quality Factor by Using Visual Basic .NET
ID: Q324788


Thanks,
-Greg
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.


--------------------
| From: "Roger" <roger...@hotmail.com>
| References: <uHNmk2sLCHA.2452@tkmsftngp08> <WkCZYOzLCHA.3204@cpmsftngxa07>
| Subject: Re: Graphics and resizing images better than
Image.GetThumbnailImage quality
| Date: Fri, 19 Jul 2002 19:48:03 -0500
| Lines: 104


| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

| Message-ID: <#7Kv2a4LCHA.2004@tkmsftngp10>
| Newsgroups: microsoft.public.dotnet.framework.drawing
| NNTP-Posting-Host: 12.238.222.48
| Path: cpmsftngxa07!tkmsftngp01!tkmsftngp10
| Xref: cpmsftngxa07 microsoft.public.dotnet.framework.drawing:2538
| X-Tomcat-NG: microsoft.public.dotnet.framework.drawing

Roger Meike

unread,
Jul 26, 2002, 2:10:08 PM7/26/02
to
Excuse my ignorance, but where do I find these articles? I couldn't find
them via search on MSDN...

-roger

"Greg Binkerd [MS]" <Gr...@online.microsoft.com> wrote in message

news:NDgRijZMCHA.2016@cpmsftngxa07...

Larry Serflaten

unread,
Jul 27, 2002, 1:19:41 AM7/27/02
to
"Roger Meike" <ro...@dontemail.me> wrote in message news:uq3uT#MNCHA.2260@tkmsftngp10...

> Excuse my ignorance, but where do I find these articles? I couldn't find
> them via search on MSDN...

> >


> > INFO: Determine the JPEG Quality Factor by Using Visual C# .NET
> > ID: Q324790
> >
> > INFO: Determine JPEG Quality Factor by Using Visual Basic .NET
> > ID: Q324788

Go to the KB search page and paste the ID number in the box at the top of
the far left column, or in the 'Search for...' box, or scroll down about 2/3rds
of the page and enter it in the box provided there (that's the more direct route).

KB Search page:
http://support.microsoft.com/default.aspx?scid=fh;en-us;kbinfo

LFS

martin

unread,
Aug 1, 2002, 10:46:58 AM8/1/02
to
I had the same problem a while ago... the way I fixed it was to rotate
the image 360 degrees before doing any thumbnails. I don't know why,
but this seems to produce better quality images.

eg:

System.Drawing.Image img = System.Drawing.Image.FromFile("myimg.jpg");

img.RotateFlip(RotateFlipType.Rotate180FlipNone);
img.RotateFlip(RotateFlipType.Rotate180FlipNone);

img.GetThumbnailImage(80, 80, null, new IntPtr());

0 new messages