简体   繁体   中英

Drop a Page/Layer from Tiff/SVS File

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM