Class TiffFrame

Class TiffFrame

Namespace: Aspose.Imaging.FileFormats.Tiff
Assembly: Aspose.Imaging.dll (25.7.0)

The tiff frame.

[JsonObject(MemberSerialization.OptIn)]
   public sealed class TiffFrame : RasterCachedImage, IDisposable, IObjectWithBounds,
      IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasExifData, IHasXmpData, IHasMetadata
   {
   }

Inheritance

object DisposableObject DataStreamSupporter Image RasterImage RasterCachedImage TiffFrame

Implements

IDisposable , IObjectWithBounds , IRasterImageArgb32PixelLoader , IRasterImageRawDataLoader , IHasExifData , IHasXmpData , IHasMetadata

Inherited Members

RasterCachedImage.CacheData() , RasterCachedImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedImage.Resize(int, int, ResizeType) , RasterCachedImage.Resize(int, int, ImageResizeSettings) , RasterCachedImage.RotateFlip(RotateFlipType) , RasterCachedImage.Rotate(float, bool, Color) , RasterCachedImage.Crop(Rectangle) , RasterCachedImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedImage.Grayscale() , RasterCachedImage.NormalizeHistogram() , RasterCachedImage.BinarizeFixed(byte) , RasterCachedImage.BinarizeOtsu() , RasterCachedImage.BinarizeBradley(double, int) , RasterCachedImage.BinarizeBradley(double) , RasterCachedImage.AdjustBrightness(int) , RasterCachedImage.AdjustContrast(float) , RasterCachedImage.AdjustGamma(float, float, float) , RasterCachedImage.AdjustGamma(float) , RasterCachedImage.IsCached , RasterImage.RemoveMetadata() , RasterImage.Save(Stream, ImageOptionsBase, Rectangle) , RasterImage.GetModifyDate(bool) , RasterImage.Dither(DitheringMethod, int) , RasterImage.Dither(DitheringMethod, int, IColorPalette) , RasterImage.GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings) , RasterImage.GetDefaultArgb32Pixels(Rectangle) , RasterImage.GetDefaultRawData(Rectangle, RawDataSettings) , RasterImage.GetArgb32Pixel(int, int) , RasterImage.GetPixel(int, int) , RasterImage.SetArgb32Pixel(int, int, int) , RasterImage.SetPixel(int, int, Color) , RasterImage.ReadScanLine(int) , RasterImage.ReadArgb32ScanLine(int) , RasterImage.WriteScanLine(int, Color[]) , RasterImage.WriteArgb32ScanLine(int, int[]) , RasterImage.LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.LoadPartialPixels(Rectangle, IPartialPixelLoader) , RasterImage.LoadArgb32Pixels(Rectangle) , RasterImage.LoadArgb64Pixels(Rectangle) , RasterImage.LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader) , RasterImage.LoadPixels(Rectangle) , RasterImage.LoadCmykPixels(Rectangle) , RasterImage.LoadCmyk32Pixels(Rectangle) , RasterImage.LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.SaveRawData(byte[], int, Rectangle, RawDataSettings) , RasterImage.SaveArgb32Pixels(Rectangle, int[]) , RasterImage.SavePixels(Rectangle, Color[]) , RasterImage.SaveCmykPixels(Rectangle, CmykColor[]) , RasterImage.SaveCmyk32Pixels(Rectangle, int[]) , RasterImage.SetResolution(double, double) , RasterImage.SetPalette(IColorPalette, bool) , RasterImage.Resize(int, int, ImageResizeSettings) , RasterImage.Rotate(float, bool, Color) , RasterImage.Rotate(float) , RasterImage.BinarizeFixed(byte) , RasterImage.BinarizeOtsu() , RasterImage.BinarizeBradley(double) , RasterImage.BinarizeBradley(double, int) , RasterImage.Blend(Point, RasterImage, Rectangle, byte) , RasterImage.Blend(Point, RasterImage, byte) , RasterImage.Grayscale() , RasterImage.NormalizeHistogram() , RasterImage.AdjustBrightness(int) , RasterImage.AdjustContrast(float) , RasterImage.AdjustGamma(float, float, float) , RasterImage.AdjustGamma(float) , RasterImage.GetSkewAngle() , RasterImage.NormalizeAngle() , RasterImage.NormalizeAngle(bool, Color) , RasterImage.Filter(Rectangle, FilterOptionsBase) , RasterImage.ReplaceColor(Color, byte, Color) , RasterImage.ReplaceColor(int, byte, int) , RasterImage.ReplaceNonTransparentColors(Color) , RasterImage.ReplaceNonTransparentColors(int) , RasterImage.ToBitmap() , RasterImage.PremultiplyComponents , RasterImage.UseRawData , RasterImage.UpdateXmpData , RasterImage.XmpData , RasterImage.RawIndexedColorConverter , RasterImage.RawCustomColorConverter , RasterImage.RawFallbackIndex , RasterImage.RawDataSettings , RasterImage.UsePalette , RasterImage.RawDataFormat , RasterImage.RawLineSize , RasterImage.IsRawDataAvailable , RasterImage.HorizontalResolution , RasterImage.VerticalResolution , RasterImage.HasTransparentColor , RasterImage.HasAlpha , RasterImage.TransparentColor , RasterImage.ImageOpacity , Image.CanLoad(string) , Image.CanLoad(string, LoadOptions) , Image.CanLoad(Stream) , Image.CanLoad(Stream, LoadOptions) , Image.Create(ImageOptionsBase, int, int) , Image.Create(Image[]) , Image.Create(MultipageCreateOptions) , Image.Create(string[], bool) , Image.Create(string[]) , Image.Create(Image[], bool) , Image.GetFileFormat(string) , Image.GetFileFormat(Stream) , Image.GetFittingRectangle(Rectangle, int, int) , Image.GetFittingRectangle(Rectangle, int[], int, int) , Image.Load(string, LoadOptions) , Image.Load(string) , Image.Load(Stream, LoadOptions) , Image.Load(Stream) , Image.GetProportionalWidth(int, int, int) , Image.GetProportionalHeight(int, int, int) , Image.RemoveMetadata() , Image.CanSave(ImageOptionsBase) , Image.Resize(int, int) , Image.Resize(int, int, ResizeType) , Image.Resize(int, int, ImageResizeSettings) , Image.GetDefaultOptions(object[]) , Image.GetOriginalOptions() , Image.ResizeWidthProportionally(int) , Image.ResizeHeightProportionally(int) , Image.ResizeWidthProportionally(int, ResizeType) , Image.ResizeHeightProportionally(int, ResizeType) , Image.ResizeWidthProportionally(int, ImageResizeSettings) , Image.ResizeHeightProportionally(int, ImageResizeSettings) , Image.RotateFlip(RotateFlipType) , Image.Rotate(float) , Image.Crop(Rectangle) , Image.Crop(int, int, int, int) , Image.Save() , Image.Save(string) , Image.Save(string, ImageOptionsBase) , Image.Save(string, ImageOptionsBase, Rectangle) , Image.Save(Stream, ImageOptionsBase) , Image.Save(Stream, ImageOptionsBase, Rectangle) , Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , Image.SetPalette(IColorPalette, bool) , Image.BitsPerPixel , Image.Bounds , Image.Container , Image.Height , Image.Palette , Image.UsePalette , Image.Size , Image.Width , Image.InterruptMonitor , Image.BufferSizeHint , Image.AutoAdjustPalette , Image.HasBackgroundColor , Image.FileFormat , Image.BackgroundColor , DataStreamSupporter.CacheData() , DataStreamSupporter.Save() , DataStreamSupporter.Save(Stream) , DataStreamSupporter.Save(string) , DataStreamSupporter.Save(string, bool) , DataStreamSupporter.DataStreamContainer , DataStreamSupporter.IsCached , DisposableObject.Dispose() , DisposableObject.Disposed , object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

This example shows how to create a TIFF image from scratch and save it to a file.

string dir = "c:\\temp\\";
   Aspose.Imaging.ImageOptions.TiffOptions createOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
   createOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
   createOptions.ByteOrder = Aspose.Imaging.FileFormats.Tiff.Enums.TiffByteOrder.BigEndian;
   createOptions.Compression = Aspose.Imaging.FileFormats.Tiff.Enums.TiffCompressions.Lzw;
   createOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
   createOptions.PlanarConfiguration = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPlanarConfigs.Contiguous;
   Aspose.Imaging.FileFormats.Tiff.TiffFrame firstFrame = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(createOptions, 100, 100);
   Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
       new Aspose.Imaging.Point(0, 0),
       new Aspose.Imaging.Point(firstFrame.Width, firstFrame.Height),
       Aspose.Imaging.Color.Blue,
       Aspose.Imaging.Color.Yellow);
   Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(firstFrame);
   graphics.FillRectangle(gradientBrush, firstFrame.Bounds);
   using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = new Aspose.Imaging.FileFormats.Tiff.TiffImage(firstFrame))
   {
      tiffImage.Save(dir + "output.tif");
   }

Constructors

TiffFrame(Stream)

Initializes a new instance of the Aspose.Imaging.FileFormats.Tiff.TiffFrame class.

public TiffFrame(Stream stream)
   {
   }

Parameters

stream Stream

The stream to load an image from and initialize frame pixel and palette data with.

TiffFrame(Stream, TiffOptions)

Initializes a new instance of the Aspose.Imaging.FileFormats.Tiff.TiffFrame class.

public TiffFrame(Stream stream, TiffOptions options)
{
}

Parameters

stream Stream

The stream to load an image from and initialize frame pixel and palette data with.

options TiffOptions

The options to use for the newly created frame.

TiffFrame(string)

Initializes a new instance of the Aspose.Imaging.FileFormats.Tiff.TiffFrame class.

public TiffFrame(string path)
   {
   }

Parameters

path string

The path to load an image from and initialize frame pixel and palette data with.

TiffFrame(string, TiffOptions)

Initializes a new instance of the Aspose.Imaging.FileFormats.Tiff.TiffFrame class.

public TiffFrame(string path, TiffOptions options)
   {
   }

Parameters

path string

The path to load an image from and initialize frame pixel and palette data with.

options TiffOptions

The options to use for the newly created frame.

TiffFrame(RasterImage)

Initializes a new instance of the Aspose.Imaging.FileFormats.Tiff.TiffFrame class.

public TiffFrame(RasterImage image)
   {
   }

Parameters

image RasterImage

The image to initialize frame pixel and palette data with.

Examples

The following example shows how to compose a mutlipage TIFF from individual raster images.

Aspose.Imaging.ImageOptions.TiffOptions createTiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
   createTiffOptions.Source = new Aspose.Imaging.Sources.FileCreateSource("c:\\temp\\multipage.tif", false);
   createTiffOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
   createTiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
   using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Image.Create(createTiffOptions, 100, 100))
   {
       Aspose.Imaging.Font font = new Aspose.Imaging.Font("Arial", 64);
       Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.White);
       for (int i = 1; i <= 5; i++)
       {
           Aspose.Imaging.ImageOptions.PngOptions createPngOptions = new Aspose.Imaging.ImageOptions.PngOptions();
           createPngOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
           Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)Image.Create(createPngOptions, 100, 100);
           Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(pngImage);
           gr.DrawString(i.ToString(), font, brush, 10, 10);
           Aspose.Imaging.FileFormats.Tiff.TiffFrame frame = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(pngImage);
           tiffImage.AddFrame(frame);
       }
       Aspose.Imaging.FileFormats.Tiff.TiffFrame activeFrame = tiffImage.ActiveFrame;
       tiffImage.ActiveFrame = tiffImage.Frames[1];
       tiffImage.RemoveFrame(0);
       activeFrame.Dispose();
       tiffImage.Save();
   }

TiffFrame(RasterImage, TiffOptions)

Initializes a new instance of the Aspose.Imaging.FileFormats.Tiff.TiffFrame class.

public TiffFrame(RasterImage image, TiffOptions options)
   {
   }

Parameters

image RasterImage

The image to initialize frame pixel and palette data with.

options TiffOptions

The options to use for the newly created frame.

TiffFrame(TiffOptions, int, int)

Initializes a new instance of the Aspose.Imaging.FileFormats.Tiff.TiffFrame class.

public TiffFrame(TiffOptions options, int width, int height)
   {
   }

Parameters

options TiffOptions

The frame options.

width int

The width.

height int

The height.

Examples

This example shows how to create a TIFF image from scratch and save it to a file.

string dir = "c:\\temp\\";
   Aspose.Imaging.ImageOptions.TiffOptions createOptions = new Aspose.Imaging.ImageOptions.TiffOptions(
      Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
   createOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
   createOptions.ByteOrder = Aspose.Imaging.FileFormats.Tiff.Enums.TiffByteOrder.BigEndian;
   createOptions.Compression = Aspose.Imaging.FileFormats.Tiff.Enums.TiffCompressions.Lzw;
   createOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
   createOptions.PlanarConfiguration = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPlanarConfigs.Contiguous;
   Aspose.Imaging.FileFormats.Tiff.TiffFrame firstFrame = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(createOptions, 100, 100);
   Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
      new Aspose.Imaging.Point(0, 0),
      new Aspose.Imaging.Point(firstFrame.Width, firstFrame.Height),
      Aspose.Imaging.Color.Blue,
      Aspose.Imaging.Color.Yellow);
   Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(firstFrame);
   graphics.FillRectangle(gradientBrush, firstFrame.Bounds);
   using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = new Aspose.Imaging.FileFormats.Tiff.TiffImage(firstFrame))
   {
      tiffImage.Save(dir + "output.tif");
   }

This example shows how to create a TIFF image with 2 frames and save it to a file.

string dir = "c:\\temp\\";
   Aspose.Imaging.ImageOptions.TiffOptions createOptions1 = new Aspose.Imaging.ImageOptions.TiffOptions(Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
   createOptions1.BitsPerSample = new ushort[] { 8, 8, 8 };
   createOptions1.ByteOrder = Aspose.Imaging.FileFormats.Tiff.Enums.TiffByteOrder.BigEndian;
   createOptions1.Compression = Aspose.Imaging.FileFormats.Tiff.Enums.TiffCompressions.Lzw;
   createOptions1.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
   createOptions1.PlanarConfiguration = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPlanarConfigs.Contiguous;
   Aspose.Imaging.FileFormats.Tiff.TiffFrame frame1 = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(createOptions1, 100, 100);
   Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
       new Aspose.Imaging.Point(0, 0),
       new Aspose.Imaging.Point(frame1.Width, frame1.Height),
       Aspose.Imaging.Color.Blue,
       Aspose.Imaging.Color.Yellow);
   Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(frame1);
   graphics.FillRectangle(gradientBrush, frame1.Bounds);
   Aspose.Imaging.ImageOptions.TiffOptions createOptions2 = new Aspose.Imaging.ImageOptions.TiffOptions(Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
   createOptions2.BitsPerSample = new ushort[] { 1 };
   createOptions2.ByteOrder = Aspose.Imaging.FileFormats.Tiff.Enums.TiffByteOrder.LittleEndian;
   createOptions2.Compression = Aspose.Imaging.FileFormats.Tiff.Enums.TiffCompressions.CcittFax3;
   createOptions2.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.MinIsBlack;
   Aspose.Imaging.FileFormats.Tiff.TiffFrame frame2 = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(createOptions2, 200, 200);
   Aspose.Imaging.Graphics graphics2 = new Aspose.Imaging.Graphics(frame2);
   graphics2.FillRectangle(gradientBrush, frame2.Bounds);
   using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = new Aspose.Imaging.FileFormats.Tiff.TiffImage(
       new Aspose.Imaging.FileFormats.Tiff.TiffFrame[] { frame1, frame2 }))
   {
       tiffImage.Save(dir + "output.multiframe.tif");
   }

Exceptions

ArgumentNullException

Options parameter is null.

Properties

BackgroundColor

Gets or sets a value for the background color.

public override Color BackgroundColor
    {
        get;
        set;
    }

Property Value

Color

BitsPerPixel

Gets the image bits per pixel count.

public override int BitsPerPixel
   {
      get;
   }

Property Value

int

ExifData

Gets or sets EXIF data from frame.

public ExifData ExifData
   {
      get;
      set;
   }

Property Value

ExifData

FrameOptions

Gets the frame create options.

public TiffOptions FrameOptions
   {
      get;
   }

Property Value

TiffOptions

HasAlpha

Gets a value indicating whether this instance has alpha.

public override bool HasAlpha
   {
      get;
   }

Property Value

bool

Examples

The following example loads a TIFF image and prints information about raw data format and alpha channel.

string dir = "c:\\temp\\";
   string fileName = dir + "sample.tif";
   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(fileName))
   {
       Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
       System.Console.WriteLine("ImageFile={0}, FileFormat={1}, HasAlpha={2}", fileName, tiffImage.RawDataFormat, tiffImage.HasAlpha);
       int i = 0;
       foreach (Aspose.Imaging.FileFormats.Tiff.TiffFrame frame in tiffImage.Frames)
       {
           System.Console.WriteLine("Frame={0}, FileFormat={1}, HasAlpha={2}", ++i, frame.RawDataFormat, frame.HasAlpha);
       }
   }

HasTransparentColor

Gets a value indicating whether image has transparent color.

public override bool HasTransparentColor
   {
      get;
      set;
   }

Property Value

bool

Height

Gets the image height.

public override int Height
   {
      get;
   }

Property Value

int

HorizontalResolution

Gets or sets the horizontal resolution, in pixels per inch, of this Aspose.Imaging.RasterImage.

public override double HorizontalResolution
{
    get;
    set;
}

Property Value

double

Examples

The following example shows how to set horizontal/vertical resolution of a separate TIFF frame.

string dir = "c:\\temp\\";
   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
   {
       Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
       int i = 0;
       foreach (Aspose.Imaging.FileFormats.Tiff.TiffFrame frame in tiffImage.Frames)
       {
           double horizontalResolution = frame.HorizontalResolution;
           double verticalResolution = frame.VerticalResolution;
           System.Console.WriteLine("The horizontal resolution of frame {0}, pixels per inch: {1}", i, horizontalResolution);
           System.Console.WriteLine("The vertical resolution, of frame {0}, pixels per inch: {1}", i, verticalResolution);
           if (horizontalResolution != 96.0 || verticalResolution != 96.0)
           {
               System.Console.WriteLine("Set resolution values to 96 dpi");
               frame.SetResolution(96.0, 96.0);
               System.Console.WriteLine("The horizontal resolution of frame {0}, pixels per inch: {1}", i, horizontalResolution);
               System.Console.WriteLine("The vertical resolution, of frame {0}, pixels per inch: {1}", i, verticalResolution);
           }
           ++i;
       }
   }

PathResources

Gets or sets the path resources.

public List<PathResource> PathResources { get; set; }

Property Value

List < PathResource >

Examples

Transfer Clipping Paths during export from TIFF to PSD image.

using (var image = Image.Load("Sample.tif"))
   {
       image.Save("SampleWithPaths.psd", new PsdOptions());
   }

The following example shows how to retrieve paths from TIFF image and display their names in the console.

using (var image as TiffImage = Image.Load("Sample.tif"))
   {
       foreach (var path in image.ActiveFrame.PathResources)
       {
           Console.WriteLine(path.Name);
       }
   }

The following example shows how to modify already existing Clipping Paths. For instance, you can keep only one Clipping Path in the image.

using (var image as TiffImage = Image.Load("Sample.tif"))
   {
       var paths = image.ActiveFrame.PathResources;
       image.ActiveFrame.PathResources = paths.Take(1).ToList();
       image.Save();
   }

The following example shows how to create Clipping Path in TIFF image. In order to do that you need to create an instance of PathResource class. The following code demonstrates the way how you can create an empty path in TIFF image.

var options = new TiffOptions(TiffExpectedFormat.Default);
   var frame = new TiffFrame(options, 800, 600);
   using (var image = new TiffImage(frame))
   {
       image.ActiveFrame.PathResources = new List<PathResource>
       {
           new PathResource
           {
               BlockId = 2000,
               Name = "My Clipping Path",
               Records = new List<VectorPathRecord>()
           }
       };
       image.Save("ImageWithEmptyPath.tiff");
   }
This code has been reformatted according to C# conventions for indentation, spacing, and general readability improvements.

Create Clipping Path manually.

static void Main()
   {
       using (var image = (TiffImage)Image.Load("Sample.tif"))
       {
           image.ActiveFrame.PathResources = new List<PathResource>
           {
               new PathResource
               {
                   BlockId = 2000, // Block Id according to Photoshop specification
                   Name = "My Clipping Path", // Path name
                   Records = CreateRecords(0.2f, 0.2f, 0.8f, 0.2f, 0.8f, 0.8f, 0.2f, 0.8f) // Create path records using coordinates
               }
           };
           image.Save("ImageWithPath.tif");
       }
       private static List<VectorPathRecord> CreateRecords(params float[] coordinates)
       {
           return CreateBezierRecords(coordinates).ToList();
       }
       private static List<VectorPathRecord> CreateBezierRecords(float[] coordinates)
       {
           return CoordinatesToPoints(coordinates)
               .Select(CreateBezierRecord)
               .ToList();
       }
       private static IEnumerable<PointF> CoordinatesToPoints(float[] coordinates)
       {
           for (var index = 0; index < coordinates.Length; index += 2)
               yield return new PointF(coordinates[index], coordinates[index + 1]);
       }
       private static VectorPathRecord CreateBezierRecord(PointF point)
       {
           return new BezierKnotRecord { PathPoints = new[] { point, point, point } };
       }

VerticalResolution

Gets or sets the vertical resolution, in pixels per inch, of this Aspose.Imaging.RasterImage.

public override double VerticalResolution
    {
        get;
        set;
    }

Property Value

double

Examples

The following example shows how to set horizontal/vertical resolution of a separate TIFF frame.

string dir = "c:\\temp\\";
   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
   {
       Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
       int i = 0;
       foreach (Aspose.Imaging.FileFormats.Tiff.TiffFrame frame in tiffImage.Frames)
       {
           double horizontalResolution = frame.HorizontalResolution;
           double verticalResolution = frame.VerticalResolution;
           Console.WriteLine("The horizontal resolution of frame {0}, pixels per inch: {1}", i, horizontalResolution);
           Console.WriteLine("The vertical resolution, of frame {0}, pixels per inch: {1}", i, verticalResolution);
           if (horizontalResolution != 96.0 || verticalResolution != 96.0)
           {
               Console.WriteLine("Set resolution values to 96 dpi");
               frame.SetResolution(96.0, 96.0);
               Console.WriteLine("The horizontal resolution of frame {0}, pixels per inch: {1}", i, horizontalResolution);
               Console.WriteLine("The vertical resolution, of frame {0}, pixels per inch: {1}", i, verticalResolution);
           }
           ++i;
       }
   }

Width

Gets the image width.

public override int Width
   {
      get;
   }

Property Value

int

XmpData

Gets or sets Xmp data.

public override XmpPacketWrapper XmpData
   {
      get;
      set;
   }

Property Value

XmpPacketWrapper

Methods

AlignResolutions()

Helper method to make horizontal and vertical resolutions equal.

public void AlignResolutions()
   {
   }

CopyFrame(TiffFrame)

Copies the entire frame (duplicates).

public static TiffFrame CopyFrame(TiffFrame tiffFrame)
{
    var newFrame = new TiffFrame();
    newFrame.FrameIdentifier = tiffFrame.FrameIdentifier;
    if (tiffFrame.ImageDescription != null)
        newFrame.ImageDescription = new string(tiffFrame.ImageDescription.ToCharArray());
    foreach (var subifd in tiffFrame.SubIFDs)
        newFrame.SubIFDs.Add(subifd.Clone() as TiffDirectory);
    foreach (var directory in tiffFrame.Directories)
        newFrame.Directories.Add(directory.Clone() as TiffDirectory);
    return newFrame;
}

Parameters

tiffFrame TiffFrame

The tiff frame to copy.

Returns

TiffFrame

The newly copied tiff frame.

CreateFrameFrom(TiffFrame, TiffOptions)

Creates the frame from specified tiffFrame’ using the specified options’.The pixel data is preserved but converted to the desired format.

public static TiffFrame CreateFrameFrom(
    TiffFrame tiffFrame,
    TiffOptions options)
{
}
In this case, your input is already well-formatted according to the C# conventions. However, if there were any inconsistencies in indentation or spacing, they would be corrected to conform with the following guidelines:
6. For multi-line statements, use consistent spacing for alignment (e.g., using spaces instead of mixing tabs and spaces).
7. Line breaks should be used to improve readability, especially when multiple operators or expressions are on one line.

Parameters

tiffFrame TiffFrame

The tiff frame to create from.

options TiffOptions

The new options to use.

Returns

TiffFrame

The newly created frame.

Examples

The following example shows how to create a grayscale copy of an existing frame and add it to a TIFF image.

string dir = "c:\\temp\\";
   Aspose.Imaging.ImageOptions.TiffOptions createTiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
   createTiffOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dir + "multipage.tif", false);
   createTiffOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
   createTiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
   using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Image.Create(createTiffOptions, 100, 100))
   {
       Aspose.Imaging.Brushes.LinearGradientBrush brush =
           new Aspose.Imaging.Brushes.LinearGradientBrush(
               new Aspose.Imaging.Point(0, 0),
               new Aspose.Imaging.Point(tiffImage.Width, tiffImage.Height),
               Aspose.Imaging.Color.Red,
               Aspose.Imaging.Color.Green);
       Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(tiffImage.ActiveFrame);
       gr.FillRectangle(brush, tiffImage.Bounds);
       Aspose.Imaging.ImageOptions.TiffOptions createTiffFrameOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
       createTiffFrameOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
       createTiffFrameOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.MinIsBlack;
       createTiffFrameOptions.BitsPerSample = new ushort[] { 8 };
       Aspose.Imaging.FileFormats.Tiff.TiffFrame grayscaleFrame = Aspose.Imaging.FileFormats.Tiff.TiffFrame.CreateFrameFrom(tiffImage.ActiveFrame, createTiffFrameOptions);
       tiffImage.AddFrame(grayscaleFrame);
       tiffImage.Save();
   }

Crop(Rectangle)

Cropping the image.

public override void
      Crop(Rectangle rectangle)
   {
   }

Parameters

rectangle Rectangle

The rectangle.

GetOriginalOptions()

Gets the options based on the original file settings.This can be helpful to keep bit-depth and other parameters of the original image unchanged.For example, if we load a black-white PNG image with 1 bit per pixel and then save it using theAspose.Imaging.DataStreamSupporter.Save(System.String) method, the output PNG image with 8-bit per pixel will be produced.To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass themto the Aspose.Imaging.Image.Save(System.String,Aspose.Imaging.ImageOptionsBase) method as the second parameter.

public override ImageOptionsBase GetOriginalOptions()
{
}
I've simply added a newline after the opening curly brace `{` to improve readability and made sure that there is a consistent spacing between the opening and closing parentheses `()` of the method.

Returns

ImageOptionsBase

The options based on the original file settings.

ReleaseManagedResources()

Releases the managed resources. Make sure no unmanaged resources are released here, since they may have been already released.

protected override void ReleaseManagedResources()
   {
       base.ReleaseManagedResources();
   }

RemoveMetadata()

Removes this image instance metadata by setting this Aspose.Imaging.Xmp.IHasXmpData.XmpData and Aspose.Imaging.Exif.IHasExifData.ExifData values to null.

public override void
    RemoveMetadata()
{
}

Resize(int, int, ResizeType)

Resizes the image.

public override void
    Resize(
        int newWidth,
        int newHeight,
        ResizeType resizeType)
{
}

Parameters

newWidth int

The new width.

newHeight int

The new height.

resizeType ResizeType

The resize type.

Rotate(float, bool, Color)

Rotate image around the center.

public override void Rotate(
       float angle,
       bool resizeProportionally,
       Color backgroundColor
   )
   {
   }

Parameters

angle float

The rotate angle in degrees. Positive values will rotate clockwise.

resizeProportionally bool

if set to ’true’ you will have your image size changed according to rotated rectangle (corner points) projections in other case that leaves dimensions untouched and only internal image contents are rotated.

backgroundColor Color

Color of the background.

SaveData(Stream)

Saves the data.

protected override void SaveData(Stream stream)
   {
   }

Parameters

stream Stream

The stream to save data to.

UpdateDimensions(int, int)

Updates the image dimensions.

protected override void UpdateDimensions(
      int newWidth,
      int newHeight
   )
   {
   }

Parameters

newWidth int

The new image width.

newHeight int

The new image height.

 English