Classe SvgOptions
Summary: Create Scalar Vector Graphics (SVG) image files with our API, utilizing versatile
options for color types and compression levels. Seamlessly customize your
SVG images with precision, ensuring optimal quality and compatibility for your design needs.
Module: aspose.imaging.imageoptions
Full Name: aspose.imaging.imageoptions.SvgOptions
Inheritance: IMetadataContainer, IHasExifData, IHasMetadata, IHasXmpData, ImageOptionsBase
Constructors
| Name | Descrizione |
|---|---|
| SvgOptions() | Inizializza una nuova istanza di SvgOptions. |
Properties
| Name | Type | Access | Descrizione |
|---|---|---|---|
| buffer_size_hint | int | r/w | Ottiene o imposta il suggerimento della dimensione del buffer, che è definito come dimensione massima consentita per tutti i buffer interni. |
| callback | ISvgResourceKeeperCallback | r/w | Ottiene o imposta la strategia di memorizzazione per le risorse incorporate di SvgImage come font e raster nidificati. |
| color_type | SvgColorMode | r/w | Ottiene o imposta il tipo di colore per l’immagine SVG. |
| compress | bool | r/w | Ottiene o imposta un valore che indica se l’immagine di output deve essere compressa. |
| eliminato | bool | r | Ottiene un valore che indica se questa istanza è stata eliminata. |
| exif_data | ExifData | r/w | Ottiene o imposta i dati Exif. |
| full_frame | bool | r/w | Ottiene o imposta un valore che indica se [full frame]. |
| keep_metadata | bool | r/w | Ottiene un valore che indica se mantenere i metadati originali dell’immagine durante l’esportazione. |
| multi_page_options | MultiPageOptions | r/w | Le opzioni multipagina |
| palette | IColorPalette | r/w | Ottiene o imposta la tavolozza dei colori. |
| resolution_settings | ResolutionSetting | r/w | Ottiene o imposta le impostazioni di risoluzione. |
| source | Source | r/w | Ottiene o imposta la sorgente in cui creare l’immagine. |
| text_as_shapes | bool | r/w | Ottiene o imposta un valore che indica se il testo deve essere renderizzato come forme. |
| vector_rasterization_options | VectorRasterizationOptions | r/w | Ottiene o imposta le opzioni di rasterizzazione vettoriale. |
| xmp_data | XmpPacketWrapper | r/w | Ottiene o imposta il contenitore dei metadati XMP. |
Methods
| Name | Descrizione |
|---|---|
| clone() | Crea una clonazione membro per membro di questa istanza. |
| try_set_metadata(metadata) | Cerca di impostare un’istanza metadata, se questa istanza di Image supporta e implementa l’istanza IImageMetadataFormat. |
Constructor: SvgOptions()
SvgOptions()
Inizializza una nuova istanza di SvgOptions.
Property: compress
Ottiene o imposta un valore che indica se l’immagine di output deve essere compressa.
See also:
Example # 1: The following example shows how to convert a svg images to svgz format
Property: text_as_shapes
Ottiene o imposta un valore che indica se il testo deve essere renderizzato come forme.
See also:
Example # 1: This example shows how to load a WMF image from a file and convert it to SVG …
Method: clone()
clone()
Crea una clonazione membro per membro di questa istanza.
Returns
| Tipo | Descrizione |
|---|---|
| ImageOptionsBase | Una clonazione membro per membro di questa istanza. |
Method: try_set_metadata(metadata)
try_set_metadata(metadata)
Cerca di impostare un’istanza metadata, se questa istanza di Image supporta e implementa l’istanza IImageMetadataFormat.
Parameters:
| Parametro | Tipo | Descrizione |
|---|---|---|
| metadata | IImageMetadataFormat | I metadati. |
Returns
| Tipo | Descrizione |
|---|---|
| bool | True, se l’istanza IMetadataContainer supporta e/o implementa l’istanza IImageMetadataFormat; altrimenti, false. |
Examples
This example shows how to load a WMF image from a file and convert it to SVG using WmfRasterizationOptions.
from aspose.pycore import as_of, cast
from aspose.imaging import Image, Color, SizeF
from aspose.imaging.fileformats.wmf import WmfImage, WmfRenderMode
from aspose.imaging.imageoptions import SvgOptions, WmfRasterizationOptions
# Utilizzare Aspose.Imaging.Image.Load è un modo unificato per caricare tutti i tipi di immagini, incluso WMF.
with as_of(Image.load("test.wmf") as image:
saveOptions = SvgOptions()
# Il testo verrà convertito in forme.
saveOptions.text_as_shapes = True
rasterizationOptions = WmfRasterizationOptions()
# Il colore di sfondo della superficie di disegno.
rasterizationOptions.background_color = Color.white_smoke
# La dimensione della pagina.
rasterizationOptions.page_size = cast(SizeF, wmfImage.size)
# Se esiste un emf incorporato, renderizzare emf; altrimenti renderizzare wmf.
rasterizationOptions.render_mode = WmfRenderMode.AUTO
saveOptions.vector_rasterization_options = rasterizationOptions
wmfImage.save("test.output.svg", saveOptions)
The following example shows how to convert a svgz images to svg fromat
import aspose.pycore as aspycore
from aspose.imaging import Image, SizeF
from aspose.imaging.imageoptions import SvgRasterizationOptions, SvgOptions
from os.path import join
file: str = "example.svgz"
base_folder: str = join("D:", "Compressed")
input_file: str = join(base_folder, file)
out_file: str = input_file + ".svg"
with Image.load(input_file) as image:
obj_init = SvgRasterizationOptions()
obj_init.page_size = aspycore.cast(SizeF, image.size)
obj_init2 = SvgOptions()
obj_init2.vector_rasterization_options = obj_init
image.save(out_file, obj_init2)
The following example shows how to convert a svg images to svgz format
from os.path import join as path_combine
import aspose.pycore as aspycore
from aspose.imaging import Image, SizeF
from aspose.imaging.imageoptions import SvgRasterizationOptions, SvgOptions
file = "juanmontoya_lingerie.svg"
base_folder = path_combine("D:", "Compressed")
input_file = path_combine(base_folder, file)
out_file = input_file + ".svgz"
with Image.load(input_file) as image:
vector_rasterization_options = SvgRasterizationOptions()
vector_rasterization_options.page_size = aspycore.cast(SizeF, image.size)
obj_init2 = SvgOptions()
obj_init2.vector_rasterization_options = vector_rasterization_options
obj_init2.compress = True
image.save(out_file, obj_init2)