I have picture with a bis size as 1 MB (digital photos).
I am looking for an example to reduce the file size with c#.
After reducing I want store the smalll file in a database.
Mybe anybody has a exaplme or idea.
Thank a lot
Edi
http://weblogs.asp.net/justin_rogers/articles/131704.aspx
using System;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
public class LowerQuality {
private static void Main(string[] args) {
if ( args.Length < 2 ) {
return;
}
DirectoryInfo source = new DirectoryInfo(args[0]);
DirectoryInfo target = new DirectoryInfo(args[1]);
if ( source.Exists && target.Exists ) {
FileInfo[] files = source.GetFiles("*.jpg");
foreach(FileInfo fi in files) {
Bitmap sourceImage = new Bitmap(fi.FullName);
Bitmap targetImage = new Bitmap(800, 600);
using(Graphics gfx = Graphics.FromImage(targetImage)) {
gfx.DrawImage(
sourceImage,
new Rectangle(0, 0, targetImage.Width,
targetImage.Height),
new Rectangle(0, 0, sourceImage.Width,
sourceImage.Height),
GraphicsUnit.Pixel);
gfx.Dispose();
}
targetImage.Save(Path.Combine(target.FullName, fi.Name),
ImageFormat.Jpeg);
}
}
}
}
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Eduard Faschang" <m...@tznetz.com> wrote in message
news:O2jifUdO...@TK2MSFTNGP10.phx.gbl...
I will dry it - Edi
"Justin Rogers" <Jus...@games4dotnet.com> wrote in message
news:eRAugbdO...@TK2MSFTNGP09.phx.gbl...
Steve
"Justin Rogers" <Jus...@games4dotnet.com> wrote in message
news:eRAugbdO...@TK2MSFTNGP09.phx.gbl...