convert image format [modified]
-
can somebody please tell me what is wrong with the code below i am trying to conver some single page tif's images to group 4 compression the original format was LZW string dir = args.Length>1 ? args[0]: System.IO.Directory.GetCurrentDirectory(); dir = @"C:\Documents and Settings\caiena\Desktop\mail out DEQ\form"; string outdir= args.Length>2 ? args[1] : dir+"\\processed"; if(!System.IO.Directory.Exists(outdir)) System.IO.Directory.CreateDirectory(outdir); string[] files = System.IO.Directory.GetFiles(dir, "*.tif"); System.Console.WriteLine("input dir {0}", dir); System.Console.WriteLine("Processed dir {0}", outdir); System.Drawing.Imaging.Encoder enc = System.Drawing.Imaging.Encoder.Compression; EncoderParameters ep = new EncoderParameters(1); ImageCodecInfo info = GetEncoderInfo("image/tiff"); ep.Param[0] = new EncoderParameter(enc, (long) System.Drawing.Imaging.EncoderValue.CompressionCCITT4); foreach (string file in files) { System.IO.FileInfo fi = new System.IO.FileInfo(file); using (System.Drawing.Image img = System.Drawing.Image.FromFile(fi.FullName)) { System.Console.WriteLine("converting file {0}", outdir + fi.Name); img.Save(outdir+ fi.Name, info, ep); } } -- modified at 16:53 Monday 8th October, 2007
Thanks, Chad Aiena
-
can somebody please tell me what is wrong with the code below i am trying to conver some single page tif's images to group 4 compression the original format was LZW string dir = args.Length>1 ? args[0]: System.IO.Directory.GetCurrentDirectory(); dir = @"C:\Documents and Settings\caiena\Desktop\mail out DEQ\form"; string outdir= args.Length>2 ? args[1] : dir+"\\processed"; if(!System.IO.Directory.Exists(outdir)) System.IO.Directory.CreateDirectory(outdir); string[] files = System.IO.Directory.GetFiles(dir, "*.tif"); System.Console.WriteLine("input dir {0}", dir); System.Console.WriteLine("Processed dir {0}", outdir); System.Drawing.Imaging.Encoder enc = System.Drawing.Imaging.Encoder.Compression; EncoderParameters ep = new EncoderParameters(1); ImageCodecInfo info = GetEncoderInfo("image/tiff"); ep.Param[0] = new EncoderParameter(enc, (long) System.Drawing.Imaging.EncoderValue.CompressionCCITT4); foreach (string file in files) { System.IO.FileInfo fi = new System.IO.FileInfo(file); using (System.Drawing.Image img = System.Drawing.Image.FromFile(fi.FullName)) { System.Console.WriteLine("converting file {0}", outdir + fi.Name); img.Save(outdir+ fi.Name, info, ep); } } -- modified at 16:53 Monday 8th October, 2007
Thanks, Chad Aiena
There is some vital information missing in your post. Why do you think that there is something wrong with the code? Do you get an error message? Doesn't it do what you expect, and if so, what do you expect, and how does that differ from what you get?
--- single minded; short sighted; long gone;
-
There is some vital information missing in your post. Why do you think that there is something wrong with the code? Do you get an error message? Doesn't it do what you expect, and if so, what do you expect, and how does that differ from what you get?
--- single minded; short sighted; long gone;