Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. convert image format [modified]

convert image format [modified]

Scheduled Pinned Locked Moved C#
questiongraphics
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cmarmr
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • C cmarmr

      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

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      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;

      C 1 Reply Last reply
      0
      • G Guffa

        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;

        C Offline
        C Offline
        cmarmr
        wrote on last edited by
        #3

        i get an error saying invalid parameter on the save line

        Thanks, Chad Aiena

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups