Class AiImage

AiImage class

The Adobe Illustrator (AI) Image.

public sealed class AiImage : Image

Constructors

NameDescription
AiImage()The default constructor.

Properties

NameDescription
ActivePageIndex { get; set; }Gets or sets the index of the active page.
AutoAdjustPalette { get; set; }Gets or sets a value indicating whether automatic adjust palette.
virtual BackgroundColor { get; set; }Gets or sets a value for the background color.
override BitsPerPixel { get; }Gets the image bits per pixel count.
Bounds { get; }Gets the image bounds.
BufferSizeHint { get; set; }Gets or sets the buffer size hint which is defined max allowed size for all internal buffers.
Container { get; }Gets the Image container.
DataSection { get; }Gets the data section.
DataStreamContainer { get; }Gets the object’s data stream.
Disposed { get; }Gets a value indicating whether this instance is disposed.
override FileFormat { get; }Gets a value of file format.
FinalizeSection { get; }Gets the finalize section.
virtual HasBackgroundColor { get; set; }Gets or sets a value indicating whether image has background color.
Header { get; }Gets the header.
override Height { get; }Gets the image height.
InterruptMonitor { get; set; }Gets or sets the interrupt monitor.
override IsCached { get; }Gets a value indicating whether object’s data is cached currently and no data reading is required.
Layers { get; }Gets the layer sections.
Palette { get; set; }Gets or sets the color palette. The color palette is not used when pixels are represented directly.
SetupSection { get; }Gets the setup section.
Size { get; }Gets the image size.
virtual UsePalette { get; }Gets a value indicating whether the image palette is used.
Version { get; }Gets the version of Adobe Illustrator format.
override Width { get; }Gets the image width.
XmpData { get; }Gets or sets the XMP metadata.

Methods

NameDescription
AddLayer(AiLayerSection)Adds the AI layer section.
override CacheData()Caches the data and ensures no additional data loading will be performed from the underlying DataStreamContainer.
CanSave(ImageOptionsBase)Determines whether image can be saved to the specified file format represented by the passed save options.
Dispose()Disposes the current instance.
virtual GetDefaultOptions(object[])Gets the default options.
virtual 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 the Save 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 method as the second parameter.
Resize(int, int)Resizes the image. The default NearestNeighbourResample is used.
override Resize(int, int, ImageResizeSettings)Resizes the image.
override Resize(int, int, ResizeType)Resizes the image.
ResizeHeightProportionally(int)Resizes the height proportionally.
virtual ResizeHeightProportionally(int, ImageResizeSettings)Resizes the height proportionally.
virtual ResizeHeightProportionally(int, ResizeType)Resizes the height proportionally.
ResizeWidthProportionally(int)Resizes the width proportionally. The default NearestNeighbourResample is used.
virtual ResizeWidthProportionally(int, ImageResizeSettings)Resizes the width proportionally.
virtual ResizeWidthProportionally(int, ResizeType)Resizes the width proportionally.
override RotateFlip(RotateFlipType)Rotates, flips, or rotates and flips the image.
Save()Saves the image data to the underlying stream.
virtual Save(Stream)Saves the object’s data to the specified stream.
Save(string)Saves the object’s data to the specified file location.
Save(Stream, ImageOptionsBase)Saves the image’s data to the specified stream in the specified file format according to save options.
virtual Save(string, bool)Saves the object’s data to the specified file location.
virtual Save(string, ImageOptionsBase)Saves the object’s data to the specified file location in the specified file format according to save options.
virtual Save(Stream, ImageOptionsBase, Rectangle)Saves the image’s data to the specified stream in the specified file format according to save options.
virtual Save(string, ImageOptionsBase, Rectangle)Saves the object’s data to the specified file location in the specified file format according to save options.
override SetPalette(IColorPalette, bool)Sets the image palette.

Examples

The following example demonstrates how you can export Adobe Illustrator files to PDF format in Aspose.PSD

[C#]

string sourceFilePath = "rect2_color.ai";
string outputFilePath = "rect2_color.ai_output.pdf";
using (AiImage image = (AiImage)Image.Load(sourceFilePath))
{
    image.Save(outputFilePath, new PdfOptions());
}

The following example demonstrates how you can export AI file to PSD and PNG format in Aspose.PSD

[C#]

string sourceFileName = "form_8.ai";
string outputFileName = "form_8_export";
using (AiImage image = (AiImage)Image.Load(sourceFileName))
{
    image.Save(outputFileName + ".psd", new PsdOptions());
    image.Save(outputFileName + ".png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}

The following example demonstrates the support of the exporting Ai format to PSD, PNG, JPG, GIF and TIF formats.

[C#]

string[] sourcesFiles = new string[]
{
    @"34992OStroke",
    @"rect2_color",
};
for (int i = 0; i < sourcesFiles.Length; i++)
{
    string name = sourcesFiles[i];
    string sourceFileName = name + ".ai";

    using (AiImage image = (AiImage)Image.Load(sourceFileName))
    {
        string outFileName = name + ".psd";
        ImageOptionsBase options = new PsdOptions();
        image.Save(outFileName, options);

        outFileName = name + ".png";
        options = new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha };
        image.Save(outFileName, options);

        outFileName = name + ".jpg";
        options = new JpegOptions() { Quality = 85 };
        image.Save(outFileName, options);

        outFileName = name + ".gif";
        options = new GifOptions() { DoPaletteCorrection = false };
        image.Save(outFileName, options);

        outFileName = name + ".tif";
        options = new TiffOptions(TiffExpectedFormat.TiffDeflateRgba);
        image.Save(outFileName, options);
    }
}

See Also