←Select platform

Layers Property

Summary
Gets the number of layers in the PSD file.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public int Layers {get;} 
@property (nonatomic, assign, readonly) NSInteger layers; 
public int getLayers() 
public: 
property int Layers { 
   int get(); 
} 
Layers # get  (CodecsPsdImageInfo) 

Property Value

An integer value that represents the number of layers in the PSD file. The default value is 0.

Remarks

If this value is 0, then the PSD file does not contain any layers.

For more information on PSD layers, refer to the FILE FORMATS SPECIFICATION from Adobe.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
 
 
public void CodecsImageInfoExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // Parse the colorspace types 
   CodecsColorSpaceType[] colorSpaceTypes = (CodecsColorSpaceType[])Enum.GetValues(typeof(CodecsColorSpaceType)); 
   foreach (var colorSpaceType in colorSpaceTypes) 
   { 
      Debug.WriteLine($"Colorspace of image data: {colorSpaceType}"); 
   } 
 
   // try a GIF - CodecsGifImageInfo reference 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Eye_SavePage.gif"); 
   CodecsImageInfo info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("BitsPerPixel: {0}", info.BitsPerPixel)); 
   Debug.WriteLine(string.Format("BytesPerLine: {0}", info.BytesPerLine)); 
   Debug.WriteLine(string.Format("ColorSpace: {0}", info.ColorSpace.ToString())); 
   Debug.WriteLine(string.Format("Compression: {0}", info.Compression)); 
   Debug.WriteLine(string.Format("Fax: {0}", info.Fax)); 
   Debug.WriteLine(string.Format("Format: {0}", info.Format)); 
   if (info.Gif.HasAnimationBackground) 
      Debug.WriteLine(string.Format("Gif.AnimationBackground: {0}", info.Gif.AnimationBackground.ToString())); 
   Debug.WriteLine(string.Format("Gif.AnimationHeight: {0}", info.Gif.AnimationHeight)); 
   Debug.WriteLine(string.Format("Gif.AnimationWidth: {0}", info.Gif.AnimationWidth)); 
   if (info.Gif.HasAnimationLoop) 
      Debug.WriteLine(string.Format("Gif.AnimationLoop: {0}", info.Gif.AnimationLoop.ToString())); 
   if (info.Gif.HasAnimationPalette) 
   { 
      RasterColor[] pal = info.Gif.GetAnimationPalette(); 
      Debug.WriteLine("GifAnimationPalette:\n"); 
      for (int x = 0; x < pal.Length; x++) 
      { 
         Console.Write("{0},", pal[x]); 
      } 
      Debug.WriteLine("\n"); 
   } 
   Debug.WriteLine(string.Format("Gif.IsInterlaced: {0}", info.Gif.IsInterlaced.ToString())); 
   Debug.WriteLine(string.Format("PageNumber: {0}", info.PageNumber)); 
   Debug.WriteLine(string.Format("TotalPages: {0}", info.TotalPages)); 
 
   // try a FAX TIFF - CodecsFaxImageInfo reference 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Forms\Forms to be Recognized\Invoice", "invoice.tif"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("Width: {0}", info.Width)); 
   Debug.WriteLine(string.Format("Height: {0}", info.Height)); 
   Debug.WriteLine(string.Format("IsLink: {0}", info.IsLink.ToString())); 
   Debug.WriteLine(string.Format("IsRotated: {0}", info.IsRotated.ToString())); 
   Debug.WriteLine(string.Format("Fax.IsCompressed: {0}", info.Fax.IsCompressed.ToString())); 
   if (info.HasResolution) 
   { 
      Debug.WriteLine(string.Format("X Resolution: {0}", info.XResolution)); 
      Debug.WriteLine(string.Format("Y Resolution: {0}", info.YResolution)); 
   } 
   // CodecsTiffImageInfo 
   Debug.WriteLine(string.Format("Tiff.HasNoPalette: {0}", info.Tiff.HasNoPalette.ToString())); 
   Debug.WriteLine(string.Format("Tiff.ImageFileDirectoryOffset: {0}", info.Tiff.ImageFileDirectoryOffset.ToString())); 
   Debug.WriteLine(string.Format("Tiff.IsImageFileDirectoryOffsetValid: {0}", info.Tiff.IsImageFileDirectoryOffsetValid.ToString())); 
   Debug.WriteLine(string.Format("Tiff.IsBigTiff: {0}", info.Tiff.IsBigTiff.ToString())); 
 
   // try a PNG 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "quality.png"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("HasAlpha: {0}", info.HasAlpha.ToString())); 
   Debug.WriteLine(string.Format("HasStamp: {0}", info.HasStamp.ToString())); 
 
   // try a DICOM 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, @"DICOM", "Image1.dcm"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("IsSigned: {0}", info.IsSigned.ToString())); 
 
   // try a JPEG 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("Name: {0}", info.Name)); 
   Debug.WriteLine(string.Format("Jpeg.HasStamp: {0}", info.Jpeg.HasStamp.ToString())); // CodecsJpegImageInfo reference 
   Debug.WriteLine(string.Format("Jpeg.IsLossless: {0}", info.Jpeg.IsLossless.ToString())); 
   Debug.WriteLine(string.Format("Jpeg.IsProgressive: {0}", info.Jpeg.IsProgressive.ToString())); 
   Debug.WriteLine(string.Format("Order: {0}", info.Order.ToString())); 
   Debug.WriteLine(string.Format("SizeDisk: {0}", info.SizeDisk)); 
   Debug.WriteLine(string.Format("SizeMemory: {0}", info.SizeMemory)); 
 
   // try a PSD 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.psd"); 
   if (File.Exists(srcFileName)) 
   { 
      info = codecs.GetInformation(srcFileName, true); 
      info.GetPalette(); 
      Debug.WriteLine("Information for: {0}", srcFileName); 
      Debug.WriteLine(string.Format("Psd.Layers: {0}, channels: {1}", info.Psd.Layers, info.Psd.Channels)); // CodecsPsdImageInfo reference 
   } 
 
   // try a BMP 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ulay1.bmp"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("ViewPerspective: {0}", info.ViewPerspective)); 
 
   // try an HEIC - CodecsHeicImageInfo reference 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "clean.heic"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("HasStamp: {0}", info.Heic.HasStamp)); 
 
   // try a PST 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "DataFile.pst"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("PST info: {0}, message count: {1}", info.Pst, info.Pst.MessageCount)); // CodecsPstImageInfo reference 
 
   // Finalize cannot be called directly, it is invoked automatically. 
   // To clean up before exiting, use Dispose 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
 
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.*; 
 
 
public void codecsImageInfoExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // Try a GIF - CodecsGifImageInfo reference 
   String srcFileName = combine(LEAD_VARS_IMAGES_DIR, "Eye.gif"); 
   CodecsImageInfo info = codecs.getInformation(srcFileName, true); 
   info.getPalette(); 
   System.out.println("Information for: " + srcFileName); 
   System.out.println(String.format("BitsPerPixel: %d", info.getBitsPerPixel())); 
   System.out.println(String.format("BytesPerLine: %d", info.getBytesPerLine())); 
   System.out.println(String.format("ColorSpace: %s", info.getColorSpace().toString())); 
   System.out.println(String.format("Compression: %s", info.getCompression())); 
   System.out.println(String.format("Fax: %s", info.getFax().toString())); 
   System.out.println(String.format("Format: %s", info.getFormat().toString())); 
 
   if (info.getGif().hasAnimationBackground())  
      System.out.println(String.format("getGif.getAnimationBackground: %s", info.getGif().getAnimationBackground().toString())); 
 
   System.out.println(String.format("getGif.getAnimationHeight: %d", info.getGif().getAnimationHeight())); 
   System.out.println(String.format("getGif.getAnimationWidth: %d", info.getGif().getAnimationWidth())); 
 
   if (info.getGif().hasAnimationLoop())  
      System.out.println(String.format("getGif.getAnimationLoop: %d", info.getGif().getAnimationLoop())); 
       
   if (info.getGif().hasAnimationPalette()) { 
      RasterColor[] pal = info.getGif().getAnimationPalette(); 
      System.out.println("GifAnnimationPalette:\n"); 
 
      for (int x = 0; x < pal.length; x++)  
         System.out.println(pal[x] + ","); 
      System.out.println(); 
   } 
 
   System.out.println("getGif.isInterlaced: " + info.getGif().isInterlaced()); 
   System.out.println(String.format("PageNumber: %d", info.getPageNumber())); 
   System.out.println(String.format("TotalPages: %d", info.getTotalPages())); 
 
   // Try a FAX TIFF - CodecsFaxImageInfo reference 
   srcFileName = combine(LEAD_VARS_IMAGES_DIR, "Forms\\Forms to be Recognized\\Invoice\\invoice.tif"); 
   info = codecs.getInformation(srcFileName, true); 
   info.getPalette(); 
   System.out.println("Information for: " + srcFileName); 
   System.out.println(String.format("Width: %d", info.getWidth())); 
   System.out.println(String.format("Height: %d", info.getHeight())); 
   System.out.println("isLink: " + info.isLink()); 
   System.out.println("isRotated: " + info.isRotated()); 
   System.out.println("getFax.isCompressed: " + info.getFax().isCompressed()); 
   if (info.hasResolution()) { 
      System.out.println(String.format("X Resolution: %d", info.getXResolution())); 
      System.out.println(String.format("Y Resolution: %d", info.getYResolution())); 
   } 
 
   // CodecsTiffImageInfo 
   System.out.println("getTiff().hasNoPalette(): " + info.getTiff().hasNoPalette()); 
   System.out.println( 
         String.format("getTiff.getImageFileDirectoryOffset: %d", info.getTiff().getImageFileDirectoryOffset())); 
   System.out 
         .println("getTiff.isImageFileDirectoryOffsetValid: " + info.getTiff().isImageFileDirectoryOffsetValid()); 
   System.out.println("getTiff.isBigTiff: " + info.getTiff().isBigTiff()); 
 
   // Try a PNG 
   srcFileName = combine(LEAD_VARS_IMAGES_DIR, "PngImage.png"); 
   info = codecs.getInformation(srcFileName, true); 
   info.getPalette(); 
   System.out.println("Information for: " + srcFileName); 
   System.out.println("hasAlpha: " + info.hasAlpha()); 
   System.out.println("hasStamp: " + info.hasStamp()); 
 
   // Try a DICOM 
   srcFileName = combine(LEAD_VARS_IMAGES_DIR, "DICOM\\image1.dcm"); 
   info = codecs.getInformation(srcFileName, true); 
   info.getPalette(); 
   System.out.println("Information for: " + srcFileName); 
   System.out.println("isSigned: " + info.isSigned()); 
 
   // Try a JPEG 
   srcFileName = combine(LEAD_VARS_IMAGES_DIR, "cannon.jpg"); 
   info.getPalette(); 
   System.out.println("Information for: " + srcFileName); 
   System.out.println(String.format("Name: %s", info.getName())); 
   System.out.println("getJpeg.hasStamp: " + info.getJpeg().hasStamp()); 
   System.out.println("getJpeg.isLossLess: " + info.getJpeg().isLossless()); 
   System.out.println("getJpeg.isProgressive: " + info.getJpeg().isProgressive()); 
   System.out.println(String.format("Order: %s", info.getOrder().toString())); 
   System.out.println(String.format("SizeDisk: %s", info.getSizeDisk())); 
   System.out.println(String.format("SizeMemory: %s", info.getSizeMemory())); 
 
   /* 
    * // Try a PSD 
    * srcFileName = combine(LEAD_VARS_IMAGES_DIR, "Image1.psd"); 
    * if (!srcFileName.isEmpty()) { 
    * info = codecs.getInformation(srcFileName, true); 
    * info.getPalette(); 
    * System.out.println("Information for: " + srcFileName); 
    * System.out.println(String.format("Psd.getLayers: %d, channels: %d", 
    * info.getPsd().getLayers(), info.getPsd().getChannels())); 
    * } 
    */ 
 
   // try a BMP 
   srcFileName = combine(LEAD_VARS_IMAGES_DIR, "Ulay1.bmp"); 
   info = codecs.getInformation(srcFileName, true); 
   info.getPalette(); 
   System.out.println("Information for: " + srcFileName); 
   System.out.println(String.format("getViewPerspective: %s", info.getViewPerspective().toString())); 
 
   /* 
    *  
    * // try an HEIC - CodecsHeicImageInfo reference 
    * srcFileName = combine(LEAD_VARS_IMAGES_DIR, "clean.heic"); 
    * info = codecs.getInformation(srcFileName, true); 
    * info.getPalette(); 
    * System.out.println("Information for: " + srcFileName); 
    * System.out.println("hasStamp: " + info.getHeic().hasStamp()); 
    *  
    *  
    *  
    * // try a PST 
    * srcFileName = combine(LEAD_VARS_IMAGES_DIR, "DataFile.pst"); 
    * info = codecs.getInformation(srcFileName, true); 
    * info.getPalette(); 
    * System.out.println("Information for: " + srcFileName); 
    * System.out.println(String.format("PST info: %s, message count: %d", 
    * info.getPst().toString(), info.getPst().getMessageCount())); 
    *  
    */ 
 
   // Finalize cannot be called directly, it is invoked automatically 
   codecs.dispose(); 
} 
Requirements

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.