1

Is there an easy way to remove/drop a layer/page/directory from a tiff/svs file in C#? I am looking to remove a specific page from a series of tiff/svs files that is simple. It would be nice if it were something like tifFile.dropLayer(0) rather than needing to copy everything from within to a copy. I have tried LibTiff for a good solution, but that is more complicated than I would prefer. I tried using their UnlinkDirectory() method, but the layer still shows after the fact (unless there is a save call or something I am missing. For that, I was doing:

using (Tiff tif = Tiff.Open(fileName, "a"))
{tif.UnlinkDirectory(4);}

I thought that it saved and wrote on the Close() method and that got invoked on Dispose(). I just need a simple open source library or some other way in .NET to accomplish this task.

Branco
  • 191
  • 1
  • 18

1 Answers1

1

I found a resolution to my problem. I was using a nuget package version of the LibTiff library. I uninstalled it, cloned their repo from Github, copied the necessary projects from that repo into my project, and things worked correctly.

I am still using the same basic code as above except I am directly calling Flush on the Tiff object rather than waiting for the Write, Close, or Dispose methods to do it for me. I still tried Flush with the nuget version before switching the source.

It seems that the problem was with either a corrupt nuget install of the package or something else in the ether.

Branco
  • 191
  • 1
  • 18