« May 2004 | Main | July 2004 »

June 9, 2004

.NET Image Resizing Console Application

I just finished creating a small .image manipulating NET console application that has several primary capabilities:

  • resize an image to a specified size (or percentage)
  • rotate an image 90 degrees counter-clockwise
  • reduce the quality

Nothing too revolutionary about the code. I'll mention a couple of the more interesting/useful pieces.

When saving an Image to a file via the Image.Save method, a codec is needed if you need to do anything custom. In my code, I needed to optionally reduce the quality of the image to a user specified value (the /Q:## option). For some reason Microsoft made retrieving a particular codec an effort left up to the developer rather than wrapping it in a handy static method.

private static ImageCodecInfo GetEncoder(string mimeType)
{
  ImageCodecInfo[] encoders = 
      ImageCodecInfo.GetImageDecoders();

for (int i = 0; i < encoders.Length; ++i) {
if (encoders[i].MimeType == mimeType) {
return encoders[i];
}
}
return null;
}


To retrieve the JPEG encoder:

ImageCodecInfo codec = GetEncoder("image/jpeg");

To set the quality parameter for the JPEG encoder:

EncoderParameters parameters = new EncoderParameters(1);
parameters.Param[0] =
new EncoderParameter(Encoder.Quality,
(long) quality);

reducedImage.Save(destinationFile, codec, parameters);


To reduce the image to the user specified value (the /W:##, /H:##, or the /S:## options), the application takes the original image and draws it to a smaller image at the best quality (using the InteroplationMode):

using (Image reducedImage = 
new Bitmap(scaleWidth,
scaleHeight,
image.PixelFormat))
{
using (Graphics g = Graphics.FromImage(reducedImage)) {
g.InterpolationMode =
InterpolationMode.HighQualityBicubic ;
g.DrawImage(image, resizedRect);
}
... continues ...

The remainder of the code is house keeping, dealing with handling the various command line parameters and displaying help text. By default, the application creates the modified version of the image in a "Modified" subfolder (a subfolder of the original image's folder). To overwrite the image, use the /O option. The application displays the help text if no command line parameters are provided.


I haven't tested the application extensively. Use at your own risk.


The full code and executable is here: resize.zip.

June 1, 2004

GE Advantium Oven - Four Months Later

According to my web site statistics, I see that someone was interested in "negative aspects to the GE Advantium" oven. Since we own an Advantium oven, I thought I'd take a moment to discuss the good and bad about the oven since we've been using it for about 4 months now. We have the wall oven model which looks much like a typical wall oven, although not quite as tall.

Great/Good

  • We can cook things that would have required the oven much more quickly. It's awesome for last minute decisions. I can decide to make a toasted garlic bread with cheese side for a meal and in 4 minutes, it comes out toasty and tasty, without the feeling that it was microwaved (which, if you choose to use the manual mode, you can selectively control).
  • Pizzas -- fast! We had a frozen pizza last night -- from start to finish cooked in 9:15 seconds.
  • Fast cookies.
  • Gadget-y. All ovens should be this versatile!
  • Crisp foods, oven quality. Microwave-style egg rolls come out crispy, not soggy (although see the bad list for a sticky problem).

Bad

  • Things stick to the metal pans sometimes quite fiercely. I'm never sure what will stick, or how to prevent it always. Usually not terrible, but it can be quite destructive to an egg-roll for instance when part of the the egg roll remains stuck to the pan after removal.
  • Loud. The wall mounted unit is quite loud when running. There are some very noisy fans built in to keep the unit cool. The positive side is that they don't run very long after the unit has stopped heating (depends primarily on how long the oven was used and what settings were active). It's loud enough that you wouldn't want to eat with it running. We have a second oven -- a convection oven -- which isn't nearly as noisy as the Advantium.
  • Manual microwave mode only has settings in 15 second intervals and the menu system isn't as obvious as a typical microwave
  • Only a 12 inch circular cooking surface.
  • Intimidating. My wife still hasn't used it much, in part because we have a second microwave tucked away underneath the countertop. I admit that I typically will use the microwave first if I want to defrost or just do "microwave only" things.
  • Minor: Being a geek, I wish there was a way to upgrade the menus to include new recipes (not aware of any way to do this besides the option of programming in custom recipes). Maybe in a future version and future kitchen ...

Unknowns

  • We really haven't experimented with the variety of menus much yet. Hopefully now that the house is starting to feel settled, I'll read through the included cookbook to look for some of the more interesting recipes.

Update! I've created a new review here, several years after this post with a few recipes, and further feelings on the advantium.

Help support my web site by searching and buying through Amazon.com (in assocation with Amazon.com).