c# - Get ImageUniqueID in .tiff images -
with following code-snippet uniqueimageid of .jpg image. same code doesn't work .tiff files. has idea? thx
image myimage = new bitmap(@"c:\path\to\picture.tiff"); system.text.asciiencoding encoding = new system.text.asciiencoding(); propertyitem pi = myimage.getpropertyitem(42016); // exif-code -> uniqueimageid string uniqueimageid = encoding.getstring(pi.value, 0, 32);
my solution:
install nuget-package: http://bitmiracle.com/libtiff/ https://www.nuget.org/packages/bitmiracle.libtiff.net/
code example:
string uniqueimageid; tiff mytiff = tiff.open(absolutepath, "r"); fieldvalue[] exififdtag = mytiff.getfield(tifftag.exififd); int exififdoffset = exififdtag[0].toint(); mytiff.readexifdirectory(exififdoffset); fieldvalue[] value = mytiff.getfield(tifftag.exif_imageuniqueid); if (value != null) { (int = 0; < value.length; i++) { uniqueimageid = value[i].tostring(); } } mytiff.close();
Comments
Post a Comment