Note that there are some explanatory texts on larger screens.

plurals
  1. POLibTiff.NET append mode bug?
    primarykey
    data
    text
    <p>I've started using LibTiff.NET for writing tiff IPTC tags lately and discovered strange behavior on some files that i have here. I'm using sample code that ships with LibTiff.NET binaries, and it works fine with most of the images, but some files are having image data corruption after these lines:</p> <pre><code>class Program { private const TiffTag TIFFTAG_GDAL_METADATA = (TiffTag)42112; private static Tiff.TiffExtendProc m_parentExtender; public static void TagExtender(Tiff tif) { TiffFieldInfo[] tiffFieldInfo = { new TiffFieldInfo(TIFFTAG_GDAL_METADATA, -1, -1, TiffType.ASCII, FieldBit.Custom, true, false, "GDALMetadata"), }; tif.MergeFieldInfo(tiffFieldInfo, tiffFieldInfo.Length); if (m_parentExtender != null) m_parentExtender(tif); } public static void Main(string[] args) { // Register the extender callback // It's a good idea to keep track of the previous tag extender (if any) so that we can call it // from our extender allowing a chain of customizations to take effect. m_parentExtender = Tiff.SetTagExtender(TagExtender); string destFile = @"d:\00000641(tiffed).tif"; File.Copy(@"d:\00000641.tif", destFile); //Console.WriteLine("Hello World!"); // TODO: Implement Functionality Here using (Tiff image = Tiff.Open(destFile, "a")) { // we should rewind to first directory (first image) because of append mode image.SetDirectory(0); // set the custom tag string value = "&lt;GDALMetadata&gt;\n&lt;Item name=\"IMG_GUID\"&gt;" + "817C0168-0688-45CD-B799-CF8C4DE9AB2B&lt;/Item&gt;\n&lt;Item" + " name=\"LAYER_TYPE\" sample=\"0\"&gt;athematic&lt;/Item&gt;\n&lt;/GDALMetadata&gt;"; image.SetField(TIFFTAG_GDAL_METADATA, value); // rewrites directory saving new tag image.CheckpointDirectory(); } // restore previous tag extender Tiff.SetTagExtender(m_parentExtender); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); } } </code></pre> <p>After opening i see mostly blank white image or multiple black and white lines instead of text that have been written there (i don't need to read\write tags to produce this behavior). I noticed this happens when image already has a custom tag (console window alerts about it) or one of tags have got 'bad value' (console window in this case says 'vsetfield:%pathToTiffFile%: bad value 0 for "%TagName%" tag').</p> <p>Original image: <a href="http://dl.dropbox.com/u/1476402/00000641.tif" rel="nofollow">http://dl.dropbox.com/u/1476402/00000641.tif</a></p> <p>Image after LibTiff.NET: <a href="http://dl.dropbox.com/u/1476402/00000641%28tiffed%29.tif" rel="nofollow">http://dl.dropbox.com/u/1476402/00000641%28tiffed%29.tif</a></p> <p>I would be grateful for any help provided.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload