Export TIFF annotations

Dear Support,

I’m trying to find out if Aspose.Imaging (or maybe Aspose.Pdf) can export TIFF annotations, specifically those in the WANG format. I need to get their metadata (color, position, text value etc.)

Can you let me know if this is possible? If yes, could you share a link to the documentation or some examples on how to do this?

Thanks in advance!

Hello, @grigonaz ,
Aspose.Imaging provides an API for processing EXIF and XMP metadata. As concerns WANG format, there is no specific class providing a useful API to manage these annotations. However a TIFF tag containing its data can be found:

var inputPath = @"input.tiff";
using (var image = Image.Load(inputPath) as TiffImage)
{
    foreach (var page in image.Pages)
    {
        var tiffPage = page as TiffFrame;
        var tags = tiffPage.FrameOptions.Tags;
        if (Array.Find(tags, t => t.Id == 32932) is TiffDataType dataType)
        {
            // now you can access WANG tag data
        }
    }
}

We also need some time to review its implementation deeper! Hope this helps!

1 Like

Hi @Denis.Sitko,
Thank you for the quick response!

From my understanding, WANG annotations are stored in the TIFF metadata in byte format. I used the code you sent in Java (using version 24.5) and, while I can access some basic tag information, unfortunately I’m unable to retrieve any detailed metadata or byte information about the tag.

String inputPath = "wang_1.tiff";
try (TiffImage image = (TiffImage) Image.load(inputPath)) {
    for (TiffFrame page : image.getFrames()) {
        TiffDataType[] tags = page.getFrameOptions().getTags();
        for (TiffDataType tag : tags) {
            if (tag.getTagId() == 32932) {
                System.out.println("ID: " + tag.getTagId());
                System.out.println("Type: " + tag.getTagType());
                System.out.println("Data size: " + tag.getDataSize());
                System.out.println("Value: " + tag.getValue());
            }
        }
    }
} catch (Exception e) {
    System.out.println("Error processing TIFF image: " + e.getMessage());
}

ID: 32932
Type: 1
Data size: 466
Value: [B@389562d6

Is it possible to get a tag’s metadata from the object returned by the getValue() method?
tag_get.png (26.5 KB)

Thank you in advance!

@grigonaz , you should find out the type of this tag to extract data. For example you could try a cast:
if (tag.getTagId() == 32932 && tag is TiffUnknownType unknown)
{
byte[] data = unknown.getData(); …
}

Here is a full list of TIFF tag types: Aspose.Imaging.FileFormats.Tiff.TiffTagTypes | Aspose.Imaging for .NET API Reference.