John
John

Reputation: 189

TiffCP called from c#

I want to use TiffCP utility to split a multipage TIFF into single page TIFF's.

I have this working by looping through the pages and calling the following code :

 string[] Spltarguments =
     {
         @"c:\multipagetif.tif," + PageToProcess,
         @"c:\singlepage.tif"         
     };
 BitMiracle.TiffCP.Program.Main(Spltarguments);

This works!

However the compression is wrong. I need it to be LZW.

So i noticed that TiffCP has compression option. This made me think i could simply run this utility on a single TIFF and pass in the LZW compression.

Tested it from the command line using :

tiffcp -c lzw singlepage.tif compressed.tif

This also worked !!

However i cant get it to run from within my C# app :-(

I tried many variations of the following code :

 string[] CompressArgs = 
     {
      "c lzw",
      singlepage.tif,
      compressed.tif
     };
 BitMiracle.TiffCP.Program.Main(CompressArgs);

Does anyone have any ideas - this is driving me mad !!

Upvotes: 1

Views: 1688

Answers (1)

Bobrovsky
Bobrovsky

Reputation: 14236

Please try changing

string[] CompressArgs = 
{
    "c lzw",
    singlepage.tif,
    compressed.tif
};
BitMiracle.TiffCP.Program.Main(CompressArgs);

to

string[] CompressArgs = 
{
    "-c",
    "lzw",
    "singlepage.tif",
    "compressed.tif"
};
BitMiracle.TiffCP.Program.Main(CompressArgs);

This should help.

Upvotes: 1

Related Questions