FJCore source available: Client-side JPEG resizing for Silverlight 2 Beta 2

Posted 13 July 2008  

Last year I was amazed by the innovation demonstrated by Fluxify, a neat online utility powered by the managed code version of Silverlight.  The guys at fluxcapacity ported libjpeg to pure managed code, so the end result is:

  • Resize images on the client - yeah, those images that come in through the OpenFileDialog
  • Save bandwidth.  Because bandwidth doesn't grow on trees
  • Wouldn't it be nice if Facebook used this, instead of their own custom ActiveX control?
  • You can show off to your friends by uploading your new 200 megapixel camera's images pretty quickly

The big news: today they posted the source to the FJCore library on Google Code, so anyone else can get involved in the bits as well!

Just to quickly show you how cool and easy this is, here's some C# from the included sample app that does the resizing of a Stream:

using (fileStream)
            {
                JpegDecoder decoder = new JpegDecoder(fileStream);
                DecodedJpeg jpeg = decoder.Decode();
                ImageResizer resizer = new ImageResizer(jpeg.Image);
                FluxJpeg.Core.Image small =
                    resizer.Resize(320, ResamplingFilters.NearestNeighbor);
                JpegEncoder encoder = new JpegEncoder(small, 90, outStream);
                encoder.Encode();

                BitmapImage image = new BitmapImage();
                outStream.Seek(0, SeekOrigin.Begin);
                image.SetSource(outStream);
                OutputImage.Source = image;
            }

That's super easy to use!  Check it out.  These guys are smart, and it's great that they're sharing their implementation for other folks.

Jeff Wilcox is a Principal SDE Architect at Microsoft on the Azure team.

Jeff lives in Seattle and is an alumnus of the University of Michigan with a degree in Computer Science.

comments powered by Disqus