[C#]
using (Bitmap bm = (Bitmap)Bitmap.FromFile(Server.MapPath("rez/felix-tchverkin-7pkN83wDZwY-unsplash.jpg"))) {
bm.Save(Server.MapPath("IG8_EncoderParameters_Quality1.jpg"), ImageFormat.Jpeg);
EncoderParameters p2 = new EncoderParameters() { Quality = 100 };
bm.Save(Server.MapPath("IG8_EncoderParameters_Quality2.jpg"), ImageFormat.Jpeg, p2);
EncoderParameters p3 = new EncoderParameters() { Interlace = true };
bm.Save(Server.MapPath("IG8_EncoderParameters_Quality3.gif"), ImageFormat.Gif, p3);
ColorPaletteType palette = new ColorPaletteType(ColorPaletteFamily.Uniform, 32);
EncoderParameters p4 = new EncoderParameters() { TransparentPoint = new PointF(10, 10), Palette = palette };
bm.Save(Server.MapPath("IG8_EncoderParameters_Quality4.gif"), ImageFormat.Gif, p4);
}
This code produces four files as output. The first two files are
jpeg images. The second is saved in high quality.
The second two files are gif images. The first is interlaced and
the second is transparent (using the color at the point 10,10 as
the transparent color).

felix-tchverkin-7pkN83wDZwY-unsplash.jpg

IG8_EncoderParameters_Quality1.jpg

IG8_EncoderParameters_Quality2.jpg

IG8_EncoderParameters_Quality3.gif

IG8_EncoderParameters_Quality4.gif
|