public void EnumTags(
Stream stream,
int pageNumber
)
- (BOOL)enumerateTagsInStream:(LTLeadStream *)stream
pageNumber:(NSInteger)pageNumber
callback:(void (^)(LTCodecsEnumTagsEventArgs *tagInfo))handler
error:(NSError **)error
public void enumTags(ILeadStream stream, int pageNumber)
public:
void EnumTags(
Stream^ stream,
int pageNumber
)
def EnumTags(self,stream,pageNumber):
stream
A Stream containing the input file image data.
pageNumber
1-based index of the page from which to enumerate the tags.
This method will fire the TagFound event for each tag found in the stream.
Currently, only TIFF and Exif files contain tags.
For multipage TIFF files, you can enumerate the tags from a particular page. Specify the page number whose tags to enumerate.
This method enumerates the standard TIFF tags and the user tags. Standard TIFF tags are less than 32767. User TIFF tags are usually between 32768 and 65535.
To enumerate the tags stored in a disk file, use EnumTags.
To read a tag value, use ReadTag and to read all the tags in a file, use ReadTags.
For general information about TIFF tags, refer to Implementing TIFF Comments and Tags.
Do not attempt to use DeleteTag to delete tags from inside the TagFound event. If you want to delete tags that you enumerate, use this event to add the tags to a list. Upon returning from EnumTags, you can delete all the tags from the list.
You can use TagsSupported to determine whether a certain file format supports tags.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Svg;
string tagsFileName;
IList<RasterTagMetadata> myTags;
void EnumTagsExample(string srcFileName, string destFileName)
{
RasterCodecs codecs = new RasterCodecs();
tagsFileName = srcFileName;
myTags = new List<RasterTagMetadata>();
codecs.TagFound += new EventHandler<CodecsEnumTagsEventArgs>(codecs_TagFound);
codecs.EnumTags(srcFileName, 1);
codecs.TagFound -= new EventHandler<CodecsEnumTagsEventArgs>(codecs_TagFound);
// We read all the tags now, save them to the file
Debug.WriteLine("{0} tags read, saving them to the destination file", myTags.Count);
codecs.WriteTags(destFileName, 1, myTags);
// Clean up
codecs.Dispose();
}
void codecs_TagFound(object sender, CodecsEnumTagsEventArgs e)
{
Debug.WriteLine("Tag: Id={0}, Count={1}, Type={2}, Cancel={3}", e.Id, e.Count, e.MetadataType, e.Cancel);
// Read this tag from the file and add it to our collection
RasterCodecs codecs = sender as RasterCodecs;
RasterTagMetadata tag = codecs.ReadTag(tagsFileName, 1, e.Id);
myTags.Add(tag);
}
import java.io.*;
import java.net.*;
import java.nio.file.Paths;
import java.util.*;
import java.time.Instant;
import java.time.Duration;
import org.junit.*;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import static org.junit.Assert.*;
import leadtools.*;
import leadtools.codecs.*;
import leadtools.codecs.RasterCodecs.FeedCallbackThunk;
import leadtools.drawing.internal.*;
import leadtools.imageprocessing.*;
import leadtools.imageprocessing.color.ChangeIntensityCommand;
import leadtools.svg.*;
String tagsFileName;
RasterCollection<RasterTagMetadata> myTags;
public void enumTagsExample() throws IOException {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
String srcFileName = combine(LEAD_VARS_IMAGES_DIR, "ocr1-4.tif");
RasterCodecs codecs = new RasterCodecs();
tagsFileName = srcFileName;
myTags = new RasterCollection<RasterTagMetadata>();
ILeadStream srcFileStream = LeadStreamFactory.create(srcFileName);
codecs.addTagFoundListener(codecsTagFound);
codecs.enumTags(srcFileStream, 1);
codecs.removeTagFoundListener(codecsTagFound);
// We read all the tags now, save them to the file
System.out.println(myTags.size() + " tags read, saving them to the destination file");
ILeadStream destFileStream = LeadStreamFactory.create(srcFileName);
codecs.writeTags(destFileStream, 1, myTags);
// Clean up
destFileStream.close();
srcFileStream.close();
codecs.dispose();
}
CodecsTagFoundListener codecsTagFound = new CodecsTagFoundListener() {
@Override
public void onTagFound(CodecsEnumTagsEvent e) {
System.out.println("Tag: Id=" + e.getId() + ", Count=" + e.getCount() + ", Type=" + e.getMetadataType()
+ ", Cancel=" + e.getCancel());
// Read this tag from the file and add it to our collection
RasterCodecs codecs = (RasterCodecs) e.getSource();
ILeadStream ls = LeadStreamFactory.create(tagsFileName);
RasterTagMetadata tag = codecs.readTag(ls, 1, e.getId());
myTags.add(tag);
try {
ls.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
};
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document