←Select platform

GetInformation(string,bool) Method

Summary

Gets the image information from a disk file.

Syntax

C#
VB
Objective-C
WinRT C#
C++
public CodecsImageInfo GetInformation( 
   string fileName, 
   bool totalPages 
) 
Public Overloads Function GetInformation( _ 
   ByVal fileName As String, _ 
   ByVal totalPages As Boolean _ 
) As Leadtools.Codecs.CodecsImageInfo 
public Leadtools.Codecs.CodecsImageInfo GetInformation(  
   string fileName, 
   bool totalPages 
) 
- (nullable LTCodecsImageInfo *)imageInformationForFile:(NSString *)file  
                                             totalPages:(BOOL)totalPages  
                                                  error:(NSError **)error 
             
 function Leadtools.Codecs.RasterCodecs.GetInformation(String,Boolean)(  
   fileName , 
   totalPages  
) 
public: 
Leadtools.Codecs.CodecsImageInfo^ GetInformation(  
   String^ fileName, 
   bool totalPages 
)  

Parameters

fileName
String containing the input file name to query.

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

Return Value

A CodecsImageInfo object that contains the information about the specified image.

Remarks

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

To quickly query the number of an image, use GetTotalPages or GetTotalPagesAsync.

To quickly query the format of an image, use GetFormat or GetFormatAsync.

Example

C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
using LeadtoolsExamples.Common; 
 
public void GetInformationStringExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // Get Information on a GIF image file and write it out 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "eye.gif"); 
   CodecsImageInfo info = codecs.GetInformation(srcFileName, true); 
   Console.WriteLine("Information for: {0}", srcFileName); 
   Console.WriteLine(string.Format("BitsPerPixel: {0}", info.BitsPerPixel)); 
   Console.WriteLine(string.Format("BytesPerLine: {0}", info.BytesPerLine)); 
   Console.WriteLine(string.Format("ColorSpace: {0}", info.ColorSpace.ToString())); 
   Console.WriteLine(string.Format("Compresion: {0}", info.Compression)); 
   Console.WriteLine(string.Format("Fax: {0}", info.Fax)); 
   Console.WriteLine(string.Format("Format: {0}", info.Format)); 
   if (info.Gif.HasAnimationBackground) 
      Console.WriteLine(string.Format("Gif.AnimationBackground: {0}", info.Gif.AnimationBackground.ToString())); 
   Console.WriteLine(string.Format("Gif.AnimationHeight: {0}", info.Gif.AnimationHeight)); 
   Console.WriteLine(string.Format("Gif.AnimationWidth: {0}", info.Gif.AnimationWidth)); 
   if (info.Gif.HasAnimationLoop) 
      Console.WriteLine(string.Format("Gif.AnimationLoop: {0}", info.Gif.AnimationLoop.ToString())); 
   if (info.Gif.HasAnimationPalette) 
   { 
      RasterColor[] pal = info.Gif.GetAnimationPalette(); 
      Console.WriteLine("GifAnimationPalette:\n"); 
      for (int x = 0; x < pal.Length; x++) 
      { 
         Console.Write("{0},", pal[x]); 
      } 
      Console.WriteLine("\n"); 
   } 
   Console.WriteLine(string.Format("Gif.IsInterlaced: {0}", info.Gif.IsInterlaced.ToString())); 
   Console.WriteLine(string.Format("PageNumber: {0}", info.PageNumber)); 
   Console.WriteLine(string.Format("TotalPages: {0}", info.TotalPages)); 
 
   // Clean up 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing 
Imports Leadtools.ImageProcessing.Color 
Imports Leadtools.Drawing 
Imports Leadtools.Svg 
 
Public Sub GetInformationStringExample() 
   Dim codecs As RasterCodecs = New RasterCodecs() 
 
   ' Get Information on a GIF image file and write it out 
   Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "eye.gif") 
   Dim info As CodecsImageInfo = codecs.GetInformation(srcFileName, True) 
   Console.WriteLine("Information for: {0}", srcFileName) 
   Console.WriteLine(String.Format("BitsPerPixel: {0}", info.BitsPerPixel)) 
   Console.WriteLine(String.Format("BytesPerLine: {0}", info.BytesPerLine)) 
   Console.WriteLine(String.Format("ColorSpace: {0}", info.ColorSpace.ToString())) 
   Console.WriteLine(String.Format("Compresion: {0}", info.Compression)) 
   Console.WriteLine(String.Format("Fax: {0}", info.Fax)) 
   Console.WriteLine(String.Format("Format: {0}", info.Format)) 
   If info.Gif.HasAnimationBackground Then 
      Console.WriteLine(String.Format("Gif.AnimationBackground: {0}", info.Gif.AnimationBackground.ToString())) 
   End If 
   Console.WriteLine(String.Format("Gif.AnimationHeight: {0}", info.Gif.AnimationHeight)) 
   Console.WriteLine(String.Format("Gif.AnimationWidth: {0}", info.Gif.AnimationWidth)) 
   If info.Gif.HasAnimationLoop Then 
      Console.WriteLine(String.Format("Gif.AnimationLoop: {0}", info.Gif.AnimationLoop.ToString())) 
   End If 
   If info.Gif.HasAnimationPalette Then 
      Dim pal As RasterColor() = info.Gif.GetAnimationPalette() 
      Console.WriteLine("GifAnimationPalette:" & Constants.vbLf) 
      Dim x As Integer = 0 
      Do While x < pal.Length 
         Console.Write("{0},", pal(x)) 
         x += 1 
      Loop 
      Console.WriteLine(Constants.vbLf) 
   End If 
   Console.WriteLine(String.Format("Gif.IsInterlaced: {0}", info.Gif.IsInterlaced.ToString())) 
   Console.WriteLine(String.Format("PageNumber: {0}", info.PageNumber)) 
   Console.WriteLine(String.Format("TotalPages: {0}", info.TotalPages)) 
 
   ' Clean up 
   codecs.Dispose() 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly