←Select platform

GetInformationAsync(RasterCodecs,ILeadStream,bool,int) Method

Summary

Asynchronously gets the image information about a specific page from a stream containing image data.

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

Parameters

rasterCodecs

RasterCodecs object to perform the operation.

stream

Stream containing the input image data to query.

totalPages

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

pageNumber

The page number to query. Pass 1 for the first page (default).

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#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
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)) 
         { 
            Debug.WriteLine("Information for: {0}", uri); 
            Debug.WriteLine("Format: {0}", info.Format); 
            Debug.WriteLine("Width: {0}", info.Width); 
            Debug.WriteLine("Height: {0}", info.Height); 
            Debug.WriteLine("BitsPerPixel: {0}", info.BitsPerPixel); 
            Debug.WriteLine("BytesPerLine: {0}", info.BytesPerLine); 
            Debug.WriteLine("PageNumber: {0}", info.PageNumber); 
            Debug.WriteLine("TotalPages: {0}", info.TotalPages); 
         } 
      } 
   } 
} 
 
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.*; 
 
 
public void getInformationAsyncExample() throws URISyntaxException, IOException { 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // 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); 
 
   // Create an ILeadStream object to the URI 
   ILeadStream leadStream = LeadStreamFactory.create(uri); 
 
   codecs.addGetInformationAsyncCompletedListener(new CodecsGetInformationAsyncCompletedListener() { 
 
      @Override 
      public void onGetInformationAsyncCompleted(CodecsGetInformationAsyncCompletedEvent e) { 
         CodecsImageInfo info = e.getInfo(); 
         System.out.printf("Image loaded from %s :%n", uri); 
         System.out.println("Format: " + info.getFormat()); 
         System.out.println("Width: " + info.getWidth()); 
         System.out.println("Height: " + info.getHeight()); 
         System.out.println("BitsPerPixel: " + info.getBitsPerPixel()); 
         System.out.println("BytesPerLine: " + info.getBytesPerLine()); 
         System.out.println("PageNumber: " + info.getPageNumber()); 
         System.out.println("TotalPages: " + info.getTotalPages()); 
      } 
   }); 
   codecs.getInformationAsync(leadStream, true, 1, null); 
   leadStream.close(); 
 
} 
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 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.