Class SvgOptions
Contents
[
Hide
]SvgOptions class
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.
public class SvgOptions : ImageOptionsBase
Constructors
Name | Description |
---|---|
SvgOptions() | The default constructor. |
Properties
Name | Description |
---|---|
BufferSizeHint { get; set; } | Gets or sets the buffer size hint which is defined max allowed size for all internal buffers. |
Callback { get; set; } | Gets or sets the storing strategy for embedded resousces of SvgImage such as fonts, nested rasters. |
ColorType { get; set; } | Gets or sets the color type for SVG image. |
Compress { get; set; } | Gets or sets a value indicating whether the output image must to be compressed. |
Disposed { get; } | Gets a value indicating whether this instance is disposed. |
FullFrame { get; set; } | Gets or sets a value indicating whether [full frame]. |
KeepMetadata { get; set; } | Gets a value whether to keep original image metadata on export. |
MultiPageOptions { get; set; } | The multipage options |
virtual Palette { get; set; } | Gets or sets the color palette. |
ProgressEventHandler { get; set; } | Gets or sets the progress event handler. |
virtual ResolutionSettings { get; set; } | Gets or sets the resolution settings. |
Source { get; set; } | Gets or sets the source to create image in. |
TextAsShapes { get; set; } | Gets or sets a value indicating whether text must be rendered as shapes. |
VectorRasterizationOptions { get; set; } | Gets or sets the vector rasterization options. |
virtual XmpData { get; set; } | Gets or sets the XMP metadata container. |
Methods
Name | Description |
---|---|
virtual Clone() | Clones this instance. |
Dispose() | Disposes the current instance. |
Examples
The following example shows how to convert a svgz images to svg fromat
[C#]
string file = "example.svgz";
string baseFolder = System.IO.Path.Combine("D:", "Compressed");
string inputFile = System.IO.Path.Combine(baseFolder, file);
string outFile = inputFile + ".svg";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFile))
{
Aspose.Imaging.ImageOptions.VectorRasterizationOptions vectorRasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions() { PageSize = image.Size};
image.Save(outFile, new Aspose.Imaging.ImageOptions.SvgOptions() {VectorRasterizationOptions = vectorRasterizationOptions});
}
The following example shows how to convert a svg images to svgz fromat
[C#]
string file = "juanmontoya_lingerie.svg";
string baseFolder = System.IO.Path.Combine("D:", "Compressed");
string inputFile = System.IO.Path.Combine(baseFolder, file);
string outFile = inputFile + ".svgz";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFile))
{
Aspose.Imaging.ImageOptions.VectorRasterizationOptions vectorRasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions() { PageSize = image.Size};
image.Save(outFile, new Aspose.Imaging.ImageOptions.SvgOptions() {VectorRasterizationOptions = vectorRasterizationOptions, Compress = true});
}
The following example shows how to convert a multipage vector image to SVG format in general way without referencing to a particular image type.
[C#]
string dir = "C:\\aspose.imaging\\net\\misc\\ImagingReleaseQATester\\Tests\\testdata\\2548";
string inputFilePath = System.IO.Path.Combine(dir, "Multipage.cdr");
string outputFilePath = System.IO.Path.Combine(dir, "Multipage.cdr.svg");
Aspose.Imaging.ImageOptionsBase exportOptions = new Aspose.Imaging.ImageOptions.SvgOptions();
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFilePath))
{
exportOptions.MultiPageOptions = null;
// Export only first two pages. In fact, only one page will be converted because SVG is not a multi-page format.
Aspose.Imaging.IMultipageImage multipageImage = image as Aspose.Imaging.IMultipageImage;
if (multipageImage != null && (multipageImage.Pages != null && multipageImage.PageCount > 2))
{
exportOptions.MultiPageOptions = new Aspose.Imaging.ImageOptions.MultiPageOptions(new Aspose.Imaging.IntRange(0, 2));
}
if (image is Aspose.Imaging.VectorImage)
{
exportOptions.VectorRasterizationOptions = (Aspose.Imaging.ImageOptions.VectorRasterizationOptions)image.GetDefaultOptions(new object[] { Aspose.Imaging.Color.White, image.Width, image.Height });
exportOptions.VectorRasterizationOptions.TextRenderingHint = Aspose.Imaging.TextRenderingHint.SingleBitPerPixel;
exportOptions.VectorRasterizationOptions.SmoothingMode = Aspose.Imaging.SmoothingMode.None;
}
image.Save(outputFilePath, exportOptions);
}
See Also
- class ImageOptionsBase
- namespace Aspose.Imaging.ImageOptions
- assembly Aspose.Imaging