Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Resizing images with jpeg compression

I have been resizing images using a similar technique to this example[1] but have found that the quality of the images it produces isn't that great (compared to resizing in Photoshop) even with the compression set to 100 - no compression.

Has everyone else found this? Is there any .NET image resizing components out there?

[1] http://myhome.spu.edu/tbuiten/4800/example.asp?filename=image.aspx

Ben
Wednesday, June 18, 2003

The low image quality is probably caused by the image resize method you use. If you resize by dropping pixels (nearest Neighbor) the result will always be mediocre at best. You have to resample instead. Bicubic resampling gives quite good results, but for top quality use either the Lanczos3 or Mitchell resample algorithm. If you make your images a lot smaller, which happens when you create thumbnails, you want to apply a sharpen filter after the resampling.

Also, a 100 JPEG quality setting does not mean no-compression. Standard JPEG is always lossy even at 100%.

Jan Derk
Wednesday, June 18, 2003

http://www.unitedbinary.com/AutoImageSize.aspx

Jason Watts
Wednesday, June 18, 2003

Thanks guys, I had a look at that component, looks good. One thing though, I use shared hosting, which means I can't install components. Do you need to install components that have a wrapper on them, or can you just drop them in the bin dir like fully managed .NET components?

I also found a good article which was very helpful at http://www.codeproject.com/useritems/imageresize.asp?target=resize%7Cimage

Ben
Wednesday, June 18, 2003

OK, as a mainly Delphi developer I shouldn't be here. Don't worry I will be gone soon. But C# supporting bicubic and bilinear resampling out of the box is pretty cool:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawinggraphicsclassinterpolationmodetopic.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/_gdiplus_using_interpolation_mode_to_control_image_quality_during_scaling_usecsharp.asp

No need for 3rd party tools there.

Jan Derk
Thursday, June 19, 2003

Oh, forgot to say that the last link shows a nice example of the difference in image quality at the bottom of the page.

Jan Derk
Thursday, June 19, 2003

Just found out that .NET uses GDI+ for all its graphics stuff. GDI+ can also be used by any win32 programming language. GDI+ is avaible by default on Windows XP. However, on W98/ME/2K, you need to distribute gdiplus.dll with your application. Windows 95 and NT without the latest SP are out of luck.

One is never to old to learn.

Jan Derk
Thursday, June 19, 2003

*  Recent Topics

*  Fog Creek Home