←Select platform

GetInformationAsync(RasterCodecs,ILeadStream,bool) Method

Summary

Asynchronously gets the image information from a stream containing image data.

Syntax
C#
public static Task<CodecsImageInfo> GetInformationAsync( 
   this RasterCodecs rasterCodecs, 
   ILeadStream stream, 
   bool totalPages 
) 

Parameters

rasterCodecs

RasterCodecs object to perform the operation.

stream

Asynchronously gets the image information from a stream containing image data.

totalPages

true to query the file for total number of pages; false, otherwise.

Return Value

A Task that represents the asynchronous operation. TResult: CodecsImageInfo object that contains the information about the specified image. See remarks about the usage of this object.

Remarks

This topic is part of RasterCodecs support for .NET async/await support. Refer to RasterCodecs Async Operations for more information.

Specifying true for totalPages can cause the process to be slow for files with large number of pages.

The RasterCodecs class supports getting information on image files asynchronously using the GetInformationAsync methods.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
using LeadtoolsExamples.Common; 
 
public async void GetInformationAsyncExample() 
{ 
   // For .NET Framework: Add a reference to Leadtools.Async to get the async support as extension methods 
   // For .NET Standard: async support is included. 
 
   // Get Information on a TIF image file and write it out 
   string address = @"https://demo.leadtools.com/images/tiff/ocr1.tif"; 
   Uri uri = new Uri(address); 
 
   using (RasterCodecs codecs = new RasterCodecs()) 
   { 
      // Create an ILeadStream object to the URI 
      using (ILeadStream leadStream = await LeadStream.Factory.FromUri(uri)) 
      { 
         using (CodecsImageInfo info = await codecs.GetInformationAsync(leadStream, true)) 
         { 
            Console.WriteLine("Information for: {0}", uri); 
            Console.WriteLine("Format: {0}", info.Format); 
            Console.WriteLine("Width: {0}", info.Width); 
            Console.WriteLine("Height: {0}", info.Height); 
            Console.WriteLine("BitsPerPixel: {0}", info.BitsPerPixel); 
            Console.WriteLine("BytesPerLine: {0}", info.BytesPerLine); 
            Console.WriteLine("PageNumber: {0}", info.PageNumber); 
            Console.WriteLine("TotalPages: {0}", info.TotalPages); 
         } 
      } 
   } 
} 

Requirements

For .NET Framework: A reference to the Leadtools.Async.dll assembly is required to use this functionality.

For .NET Standard: This functionality is included in the Leadtools.Codecs.dll assembly.

Target Platforms

Help Version 20.0.2019.9.19
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly