|
|
So we have a comparison we'll start by exporting the GIF image
using System.Drawing.
[C#]
string path = Server.MapPath("rez/laurentiu-iordache-qstGMhWuORE-unsplash.jpg");
using (System.Drawing.Bitmap bm = (System.Drawing.Bitmap)SD.Bitmap.FromFile(path)) {
bm.Save(Server.MapPath("Optimizing_GIFs_NET_7_gdireduced.gif"), SD.Imaging.ImageFormat.Gif);
}
|
|
|
Now we color reduce the bitmap down to twenty-five colors using
the ImageGlue adaptive palette. And again down to ten.
[C#]
using (Bitmap bm = (Bitmap)Bitmap.FromFile(path)) {
Effects.ReduceColors(bm, new ColorPaletteType(ColorPaletteFamily.Adaptive, 25), true);
bm.Save(Server.MapPath("Optimizing_GIFs_NET_7_igreduced25.gif"));
}
using (Bitmap bm = (Bitmap)Bitmap.FromFile(path)) {
Effects.ReduceColors(bm, new ColorPaletteType(ColorPaletteFamily.Adaptive, 10), true);
bm.Save(Server.MapPath("Optimizing_GIFs_NET_7_igreduced10.gif"));
}
|
|
|
Sample output images are shown below with respective file sizes.
You can see that the color reduced image has been exported at a
significantly reduced file size with little loss of quality.
laurentiu-iordache-qstGMhWuORE-unsplash.jpg
Optimizing_GIFs_NET_7_gdireduced.gif [118 KB]
Optimizing_GIFs_NET_7_igreduced25.gif [60 KB]
Optimizing_GIFs_NET_7_igreduced10.gif [32 KB]
|