to_image method
to_image
Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.
def to_image(self, image_file):
...
Parameter | Type | Description |
---|---|---|
image_file | str | The image file name with full path. |
Remarks
The format of the image is specified by using the extension of the file name. For example, if you specify “myfile.png”, then the image will be saved in the PNG format. The following file extensions are recognized: .bmp, .gif, .png, .jpg, .jpeg, .tiff, .tif, .emf.
If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.
to_image
Creates the chart image and saves it to a file in the specified image type.
def to_image(self, image_file, image_type):
...
Parameter | Type | Description |
---|---|---|
image_file | str | The image file name with full path. |
image_type | aspose.cells.drawing.ImageType | The image type in which to save the image. |
Remarks
The type of the image is specified by using imageType
.
The following types are supported:
ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.Emf.
If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.
to_image
Creates the chart image and saves it to a file in the Jpeg format.
def to_image(self, image_file, jpeg_quality):
...
Parameter | Type | Description |
---|---|---|
image_file | str | The image file name with full path. |
jpeg_quality | int | Jpeg quality. |
Remarks
If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.
to_image
Creates the chart image and saves it to a stream in the Jpeg format.
def to_image(self, stream, jpeg_quality):
...
Parameter | Type | Description |
---|---|---|
stream | io.RawIOBase | The output stream. |
jpeg_quality | int | Jpeg quality. |
Remarks
If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.
to_image
Creates the chart image and saves it to a stream in the specified format.
def to_image(self, stream, image_type):
...
Parameter | Type | Description |
---|---|---|
stream | io.RawIOBase | The output stream. |
image_type | aspose.cells.drawing.ImageType | The image type in which to save the image. |
Remarks
The type of the image is specified by using imageType
.
The following types are supported:
ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.Emf.
If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.
to_image
Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.
def to_image(self, image_file, options):
...
Parameter | Type | Description |
---|---|---|
image_file | str | The image file name with full path. |
options | aspose.cells.rendering.ImageOrPrintOptions | Additional image creation options |
Remarks
The format of the image is specified by using the extension of the file name. For example, if you specify “myfile.png”, then the image will be saved in the PNG format. The following file extensions are recognized: .bmp, .gif, .png, .jpg, .jpeg, .tiff, .tif, .emf.
If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. Please refer to Supported Charts List for more details.
Example
Saves to Tiff with 300 dpi and CCITT4 compression.
from aspose.cells import Workbook
from aspose.cells.rendering import ImageOrPrintOptions, TiffCompression
options = ImageOrPrintOptions()
options.horizontal_resolution = 300
options.vertical_resolution = 300
options.tiff_compression = TiffCompression.COMPRESSION_CCITT4
book = Workbook(r"test.xls")
book.worksheets[0].charts[0].to_image(r"chart.Tiff", options)
Saves to Jpeg with 300 dpi and 80 image quality.
from aspose.cells import Workbook
from aspose.cells.rendering import ImageOrPrintOptions
options = ImageOrPrintOptions()
options.horizontal_resolution = 300
options.vertical_resolution = 300
options.quality = 80
book = Workbook(r"test.xls")
book.worksheets[0].charts[0].to_image(r"chart.Jpeg", options)
to_image
Creates the chart image and saves it to a stream in the specified format.
def to_image(self, stream, options):
...
Parameter | Type | Description |
---|---|---|
stream | io.RawIOBase | The output stream. |
options | aspose.cells.rendering.ImageOrPrintOptions | Additional image creation options |
Remarks
The type of the image is specified by using options.ImageType
.
The following formats are supported:
ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.Emf.
If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. Please refer to Supported Charts List for more details.
See Also
- module
aspose.cells.charts
- class
Chart