Class TiffImage
- Namespace
- Aspose.Imaging.FileFormats.Tiff
- Assembly
- Aspose.Imaging.dll
Process Tagged Image File Format (TIFF) raster images with our API, offering comprehensive support for various resolutions and advanced editing capabilities like EXIF data manipulation and alpha channels. Normalize angles for scanned images, resize, transform to grayscale, and apply filters, gamma corrections and image parameters adjustments with ease. Seamlessly handle multi-frame TIFF files, create graphics paths, add shapes, and effortlessly save images to different formats.
public class TiffImage : RasterCachedMultipageImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IMultipageImageExt, IMultipageImage, IHasExifData, IHasXmpData, IHasMetadata
- Inheritance
-
TiffImage
- Implements
- Derived
- Inherited Members
Constructors
TiffImage(TiffFrame)
Initialize a new object of the TiffImage class, specifying the frame parameter. This constructor facilitates the creation of a TiffImage instance, allowing developers to specify the frame to be loaded or processed, streamlining Tiff image handling tasks within their applications.
public TiffImage(TiffFrame frame)
Parameters
frame
TiffFrameThe tiff frame to initialize image with.
Exceptions
- ArgumentNullException
Tiff
frame
cannot be empty.
TiffImage(TiffFrame[])
Create a new instance of the TiffImage class, providing a list of frames as a parameter. This constructor enables the initialization of a TiffImage object with multiple frames, facilitating efficient handling and processing of TIFF image sequences within software applications.
public TiffImage(TiffFrame[] frames)
Parameters
frames
TiffFrame[]The frames.
Exceptions
- ArgumentNullException
frames
Properties
ActiveFrame
Manage the active frame seamlessly, facilitating dynamic navigation and manipulation within the designated context. Empower your application to interact efficiently with multimedia content, enhancing user engagement and productivity.
public TiffFrame ActiveFrame { get; set; }
Property Value
- TiffFrame
Active frame.
ByteOrder
Toggle the byte order for TIFF files seamlessly, ensuring precise control over data interpretation. Empower your applications with the flexibility to adapt to diverse file specifications, enhancing compatibility and efficiency in data processing.
public TiffByteOrder ByteOrder { get; set; }
Property Value
- TiffByteOrder
The tiff byte order.
ExifData
Access or modify EXIF data associated with the active frame seamlessly, empowering precise control over image metadata. Enhance your application's capabilities by integrating this feature, ensuring accurate preservation and customization of essential image information.
public ExifData ExifData { get; set; }
Property Value
FileFormat
Retrieve the file format value associated with the image. This property serves as a critical aspect of image metadata retrieval, allowing software applications to identify and interpret the format of the image data efficiently.
public override FileFormat FileFormat { get; }
Property Value
Frames
Retrieve an array of TiffFrame instances, enabling comprehensive access and manipulation of individual frames within the TIFF image. Harness the power of this array to streamline image processing workflows, ensuring precise control and optimization of visual content.
public TiffFrame[] Frames { get; }
Property Value
HasAlpha
Determine whether the image has an alpha channel, providing crucial information for rendering and compositing operations. Integrate this feature to optimize visual processing workflows, ensuring accurate representation and manipulation of transparent elements.
public override bool HasAlpha { get; }
Property Value
- bool
The Has alpha channel.
HorizontalResolution
Retrieve the horizontal resolution of the specified Image in pixels per inch, facilitating precise adjustment and rendering capabilities. Access essential image metadata effortlessly, empowering streamlined image processing workflows for enhanced user experiences.
public override double HorizontalResolution { get; set; }
Property Value
- double
The horizontal resolution.
Remarks
Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.
PageCount
Retrieve the total count of pages within the specified document, facilitating efficient navigation and management of multi-page content. Incorporate this functionality to enhance user experience, enabling seamless access to comprehensive document structures.
public override int PageCount { get; }
Property Value
- int
The page count.
Pages
Access the pages of the document seamlessly, enabling dynamic navigation and manipulation within the content structure. Empower your application with efficient access to individual pages, facilitating streamlined document processing and enhanced user interaction.
public override Image[] Pages { get; }
Property Value
- Image[]
The pages.
PremultiplyComponents
Indicate if components necessitate premultiplication, ensuring efficient handling of visual elements. Enhance rendering processes by toggling this property, streamlining graphic workflows for optimized performance.
public override bool PremultiplyComponents { get; set; }
Property Value
- bool
true
if components must be premultiplied; otherwise,false
.
VerticalResolution
Access the vertical resolution of the designated Image in pixels per inch, enabling precise adjustments and rendering optimizations. Utilize essential image data effortlessly to streamline image processing workflows, ensuring superior quality and performance in your applications.
public override double VerticalResolution { get; set; }
Property Value
- double
The vertical resolution.
Remarks
Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.
Methods
Add(TiffImage)
Add the frames from the specified image seamlessly into the current frame, consolidating their content and enhancing compositional flexibility. Integrate this method to streamline frame management and manipulation within your application, facilitating efficient handling of multi-frame images.
public void Add(TiffImage image)
Parameters
image
TiffImageThe source image.
AddFrame(TiffFrame)
Incorporate the specified frame seamlessly into the image, expanding its content and versatility. Utilize this method to enhance image composition and management, empowering efficient handling of multi-frame images within your application.
public void AddFrame(TiffFrame frame)
Parameters
frame
TiffFrameThe frame to add.
AddFrames(TiffFrame[])
Integrate the array of frames seamlessly into the image, enriching its content and versatility. Utilize this method to enhance image composition and management, enabling efficient handling of multi-frame images within your application.
public void AddFrames(TiffFrame[] frames)
Parameters
frames
TiffFrame[]The frames array to add
AddPage(RasterImage)
Incorporate a new page into the existing image seamlessly, expanding its content and versatility. Utilize this method to enhance document composition and management, empowering efficient handling of multi-page images within your application.
public virtual void AddPage(RasterImage page)
Parameters
page
RasterImageThe page to add.
Exceptions
- ArgumentNullException
page
is null.
AdjustBrightness(int)
Implement brightness
adjustment for the image, allowing the
modification of overall luminance levels. Incorporate this method into your image
processing workflow to enhance visibility and improve the visual quality of
images within your application.
public override void AdjustBrightness(int brightness)
Parameters
brightness
intBrightness value.
AdjustContrast(float)
Enhance the contrast of the Image instance, amplifying the differences between its light and dark areas. Integrate this functionality to improve the visual clarity and overall quality of the image within your application.
public override void AdjustContrast(float contrast)
Parameters
contrast
floatContrast value (in range [-100; 100])
AdjustGamma(float)
Apply gamma correction to the image, adjusting pixel intensities to achieve desired color balance. Incorporate this method into your image processing workflow to enhance visual quality and improve the accuracy of subsequent analysis or display tasks within your application.
public override void AdjustGamma(float gamma)
Parameters
gamma
floatGamma for red, green and blue channels coefficient
AdjustGamma(float, float, float)
Perform gamma correction on the image using individual coefficients for red, green, and blue channels, allowing for fine-tuned adjustments of color balance and contrast. Integrate this method into your image processing pipeline to achieve precise control over color rendering and enhance visual fidelity within your application.
public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
Parameters
gammaRed
floatGamma for red channel coefficient
gammaGreen
floatGamma for green channel coefficient
gammaBlue
floatGamma for blue channel coefficient
AlignResolutions()
Implement the AlignResolutions helper method to synchronize horizontal and vertical resolutions, ensuring uniformity in image dimensions. This functionality facilitates streamlined image processing workflows by harmonizing resolution parameters, optimizing visual quality and consistency across various platforms and devices.
public void AlignResolutions()
BinarizeBradley(double, int)
Implement binarization on the image employing Bradley's adaptive thresholding algorithm with integral image thresholding. This approach dynamically computes local thresholds based on the image's neighborhood, enhancing adaptability to varying lighting conditions and ensuring robust segmentation for subsequent processing tasks within your application.
public override void BinarizeBradley(double brightnessDifference, int windowSize)
Parameters
brightnessDifference
doubleThe brightness difference between pixel and the average of an s x s window of pixels centered around this pixel.
windowSize
intThe size of s x s window of pixels centered around this pixel
BinarizeFixed(byte)
Apply binarization to the image using a predefined threshold, converting it into a binary image with distinct foreground and background regions. Incorporate this method into your image processing workflow to facilitate segmentation and feature extraction tasks, enhancing the accuracy and efficiency of image analysis within your application.
public override void BinarizeFixed(byte threshold)
Parameters
threshold
byteThreshold value. If corresponding gray value of a pixel is greater than threshold, a value of 255 will be assigned to it, 0 otherwise.
BinarizeOtsu()
Utilize Otsu thresholding to perform binarization on the image, automatically determining the optimal threshold value based on the image's histogram. Integrate this method into your image processing workflow to achieve effective segmentation and feature extraction, enhancing the accuracy and reliability of image analysis tasks within your application.
public override void BinarizeOtsu()
Crop(Rectangle)
Crop the image using a specified rectangular region, allowing precise selection of desired content. Integrate this method into your image processing workflow to efficiently remove unwanted areas and focus on essential details, enhancing the overall clarity and composition of the image.
public override void Crop(Rectangle rectangle)
Parameters
rectangle
RectangleThe rectangle.
Crop(int, int, int, int)
Perform cropping on the image by specifying shifts in the left, right, top, and bottom directions. This method enables precise selection of the desired portion of the image, facilitating efficient removal of unwanted areas and focusing on essential content. Integrate this functionality into your image processing pipeline to enhance clarity and composition as needed within your application.
public override void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameters
leftShift
intThe left shift.
rightShift
intThe right shift.
topShift
intThe top shift.
bottomShift
intThe bottom shift.
Dither(DitheringMethod, int, IColorPalette)
Execute dithering on the current image to enhance its visual quality and reduce color banding artifacts. Integrate this method into your image processing workflow to ensure smoother transitions between colors, resulting in improved overall image appearance and clarity.
public override void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)
Parameters
ditheringMethod
DitheringMethodThe dithering method.
bitsCount
intThe final bits count for dithering.
customPalette
IColorPaletteThe custom palette for dithering.
Filter(Rectangle, FilterOptionsBase)
Filter the content within the specified rectangle, applying a designated image processing filter to enhance or modify the selected region. Integrate this method into your image manipulation workflow to achieve targeted enhancements or transformations within your application.
public override void Filter(Rectangle rectangle, FilterOptionsBase options)
Parameters
rectangle
RectangleThe rectangle.
options
FilterOptionsBaseThe options.
GetOriginalOptions()
Retrieve options derived from the original file settings, facilitating seamless preservation of key parameters such as bit-depth and other essential attributes of the original image. Utilize this method to maintain fidelity and consistency in image processing tasks, ensuring optimal results without unnecessary alterations. For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the Save(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 them to the Save(string, ImageOptionsBase) method as the second parameter.
public override ImageOptionsBase GetOriginalOptions()
Returns
- ImageOptionsBase
The options based on the original file settings.
Exceptions
- TiffImageException
There is no original options that can be extracted from image
Grayscale()
Convert the image to its grayscale representation, transforming it into a single-channel image where each pixel represents intensity. Integrate this method into your image processing pipeline to simplify analysis and enhance compatibility with grayscale-based algorithms, facilitating various computer vision and image analysis tasks within your application.
public override void Grayscale()
InsertFrame(int, TiffFrame)
Insert the new frame at the specified index within the frame sequence, ensuring precise control over frame arrangement. Employ this method to manage frame sequences effectively, facilitating dynamic manipulation and organization of image content within your application.
public void InsertFrame(int index, TiffFrame frameToInsert)
Parameters
NormalizeAngle(bool, Color)
Utilize the NormalizeAngle method specifically designed for scanned text documents to rectify skewed scans, ensuring accurate alignment. Seamlessly integrate this functionality into your text processing workflows to enhance document readability and quality, improving overall efficiency in text recognition and analysis tasks. This method uses GetSkewAngle() and Rotate(float, bool, Color) methods.
public override void NormalizeAngle(bool resizeProportionally, Color backgroundColor)
Parameters
resizeProportionally
boolif 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
ColorColor of the background.
ReleaseManagedResources()
Releases the managed resources. Make sure no unmanaged resources are released here, since they may have been already released.
protected override void ReleaseManagedResources()
RemoveFrame(TiffFrame)
Efficiently remove the specified frame from the image sequence, facilitating streamlined frame management within your application. Integrate this functionality to enhance precision and flexibility in frame manipulation, ensuring seamless organization and presentation of image content.
public void RemoveFrame(TiffFrame frame)
Parameters
frame
TiffFrameThe frame to remove.
Remarks
Note: do not forget to Dispose the frame if you will not add it to some other TiffImage.
RemoveFrame(int)
Effortlessly eliminate the frame identified by its index from the image sequence, streamlining frame management within your application. Integrate this functionality to enhance efficiency and precision in frame manipulation, facilitating seamless organization and presentation of image content.
public TiffFrame RemoveFrame(int index)
Parameters
index
intIndex of frame to be removed.
Returns
- TiffFrame
The removed frame.
Remarks
Note: do not forget to Dispose the frame if you will not add it to some other TiffImage.
RemoveMetadata()
public override void RemoveMetadata()
ReplaceFrame(int, TiffFrame)
Substitute the frame at the designated position with another frame seamlessly, facilitating dynamic frame management within the image sequence. Integrate this method to enhance flexibility and precision in frame manipulation, ensuring optimal organization and presentation of image content within your application.
public TiffFrame ReplaceFrame(int index, TiffFrame frameToReplace)
Parameters
Returns
- TiffFrame
The removed frame.
Remarks
Note: do not forget to Dispose the frame if you will not add it to some other TiffImage.
Resize(int, int, ImageResizeSettings)
Adjust the size of the image based on specified settings, allowing for precise control over dimensions, aspect ratio, and scaling behavior. Integrate this method into your image processing workflow to achieve customized resizing operations tailored to the specific requirements of your application.
public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
intThe new width.
newHeight
intThe new height.
settings
ImageResizeSettingsThe resize settings.
Resize(int, int, ResizeType)
Resize the image according to a specified resizing type, facilitating flexible adjustment of image dimensions while preserving aspect ratio or applying specific scaling algorithms. Incorporate this method into your image processing workflow to achieve precise control over resizing operations within your application.
public override void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
intThe new width.
newHeight
intThe new height.
resizeType
ResizeTypeThe resize type.
ResizeHeightProportionally(int, ResizeType)
Conduct a proportional adjustment of the image's height, preserving its aspect ratio for consistent visual integrity. Employ this method to dynamically resize images within your application, ensuring optimal display across diverse platforms and devices without compromising content quality.
public override void ResizeHeightProportionally(int newHeight, ResizeType resizeType)
Parameters
newHeight
intThe new height.
resizeType
ResizeTypeType of the resize.
ResizeProportional(int, int, ResizeType)
Conduct a proportional resize operation on the image, preserving its aspect ratio
while adjusting its dimensions. Employ this method to dynamically scale images
within your application, ensuring consistent visual representation of content
integrity.
The proportional resize will resize each frame according to the ratio of newWidth
/width and newHeight
/height.
public void ResizeProportional(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
intThe new width.
newHeight
intThe new height.
resizeType
ResizeTypeThe resize type.
ResizeWidthProportionally(int, ResizeType)
Adjust the width of the image while maintaining its aspect ratio, ensuring proportional resizing for optimal visual presentation. Utilize this method to dynamically scale images within your application, facilitating consistent and aesthetically pleasing rendering across various display contexts.
public override void ResizeWidthProportionally(int newWidth, ResizeType resizeType)
Parameters
newWidth
intThe new width.
resizeType
ResizeTypeType of the resize.
Rotate(float, bool, Color)
Rotate the image around its center point by a specified angle, enabling precise orientation adjustments. Incorporate this functionality into your image processing pipeline to facilitate accurate transformations, ensuring optimal alignment and presentation of visual content within your application.
public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)
Parameters
angle
floatThe rotate angle in degrees. Positive values will rotate clockwise.
resizeProportionally
boolif 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
ColorColor of the background.
RotateFlip(RotateFlipType)
Perform rotation, flipping, or a combination of both operations exclusively on the active frame. This method allows precise manipulation of individual frames within the image sequence, enhancing flexibility in image editing and composition within your application.
public override void RotateFlip(RotateFlipType rotateFlipType)
Parameters
rotateFlipType
RotateFlipTypeThe rotate flip type.
SaveData(Stream)
Saves the object's data to the specified stream.
protected override void SaveData(Stream stream)
Parameters
stream
StreamThe stream to save the object's data to.
SetResolution(double, double)
Establishes the resolution for the specified RasterImage, enabling precise control over image rendering and display properties. Integrate this functionality to optimize visual output and ensure compatibility with diverse output devices and platforms, enhancing the overall user experience.
public override void SetResolution(double dpiX, double dpiY)
Parameters
dpiX
doubleThe horizontal resolution, in dots per inch, of the RasterImage.
dpiY
doubleThe vertical resolution, in dots per inch, of the RasterImage.
UpdateDimensions(int, int)
Updates the image dimensions.
protected override void UpdateDimensions(int newWidth, int newHeight)