Class SvgOptions

Class SvgOptions

Der Name: Aspose.Imaging.ImageOptions Versammlung: Aspose.Imaging.dll (25.4.0)

Erstellen Sie Scalar Vector Graphics (SVG) Bilddateien mit unserer API, indem Sie vielseitigeOptionen für Farbtypen und Kompressionsniveaus. Unsicher anpassen Sie IhreSVG Bilder mit Genauigkeit, optimale Qualität und Kompatibilität für Ihre Designbedürfnisse zu gewährleisten.

[JsonObject(MemberSerialization.OptIn)]
public class SvgOptions : ImageOptionsBase, IDisposable, IHasXmpData, IHasMetadata, ICloneable

Inheritance

object DisposableObject ImageOptionsBase SvgOptions

Implements

IDisposable , IHasXmpData , IHasMetadata , ICloneable

Vererbte Mitglieder

ImageOptionsBase.Clone() , ImageOptionsBase.ReleaseManagedResources() , ImageOptionsBase.KeepMetadata , ImageOptionsBase.XmpData , ImageOptionsBase.Source , ImageOptionsBase.Palette , ImageOptionsBase.ResolutionSettings , ImageOptionsBase.VectorRasterizationOptions , ImageOptionsBase.BufferSizeHint , ImageOptionsBase.MultiPageOptions , ImageOptionsBase.FullFrame , ImageOptionsBase.ProgressEventHandler , DisposableObject.Dispose() , DisposableObject.ReleaseManagedResources() , DisposableObject.ReleaseUnmanagedResources() , DisposableObject.VerifyNotDisposed() , DisposableObject.Disposed , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Das folgende Beispiel zeigt, wie man eine svgz Bilder in svg fromat umwandelt

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});
                                                                                 }

Das folgende Beispiel zeigt, wie man eine svg Bilder in svgz ausat konvertiert

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});
                                                                                 }

Das folgende Beispiel zeigt, wie man ein mehrseiten Vektorbild in SVG-Format im Allgemeinen konvertiert, ohne auf einen bestimmten Bildtyp zu beziehen.

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);
                                                                                                                                                           }

Constructors

SvgOptions()

[JsonConstructor]
public SvgOptions()

Properties

Callback

Erhalten oder setzen Sie die Speicherstrategie für eingebettete Resources von Aspose.Imaging.FileFormats.Svg.SvgImage wie Fonts, Nested Rasters.

public ISvgResourceKeeperCallback Callback { get; set; }

Eigentumswert

ISvgResourceKeeperCallback

ColorType

Erhalten oder festlegen Sie den Farbtyp für SVG Bild.

[JsonProperty]
public SvgColorMode ColorType { get; set; }

Eigentumswert

SvgColorMode

Compress

Er erhält oder stellt einen Wert an, der darauf hindeutet, ob das Ausgangsbild komprimiert werden muss.

[JsonProperty]
public bool Compress { get; set; }

Eigentumswert

bool

Examples

Das folgende Beispiel zeigt, wie man eine svg Bilder in svgz ausat konvertiert

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});
                                                                                 }

TextAsShapes

Er bekommt oder setzt einen Wert, der darauf hindeutet, ob Text als Form dargestellt werden muss.

[JsonProperty]
public bool TextAsShapes { get; set; }

Eigentumswert

bool

Examples

Dieses Beispiel zeigt, wie man ein WMF-Bild aus einem Datei laden und es in SVG mit WmfRasterizationOptions umwandeln kann.

string dir = "c:\\temp\\";

                                                                                                                      // Using Aspose.Imaging.Image.Load is a unified way to load all types of images including WMF.
                                                                                                                      using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = (Aspose.Imaging.FileFormats.Wmf.WmfImage)Aspose.Imaging.Image.Load(dir + "test.wmf"))
                                                                                                                      {
                                                                                                                          Aspose.Imaging.ImageOptions.SvgOptions saveOptions = new Aspose.Imaging.ImageOptions.SvgOptions();

                                                                                                                          // Text will be converted to shapes.
                                                                                                                          saveOptions.TextAsShapes = true;

                                                                                                                          Aspose.Imaging.ImageOptions.WmfRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.WmfRasterizationOptions();

                                                                                                                          // The background color of the drawing surface.
                                                                                                                          rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.WhiteSmoke;

                                                                                                                          // The page size.
                                                                                                                          rasterizationOptions.PageSize = wmfImage.Size;

                                                                                                                          // If embedded emf exists, then render emf; otherwise render wmf.
                                                                                                                          rasterizationOptions.RenderMode = Aspose.Imaging.FileFormats.Wmf.WmfRenderMode.Auto;

                                                                                                                          saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                          wmfImage.Save(dir + "test.output.svg", saveOptions);
                                                                                                                      }

Dieses Beispiel zeigt, wie man ein EMF-Bild aus einem Datei laden und es in SVG mit EmfRasterizationOptions umwandeln kann.

string dir = "c:\\temp\\";

                                                                                                                      // Using Aspose.Imaging.Image.Load is a unified way to load all types of images including EMF.
                                                                                                                      using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = (Aspose.Imaging.FileFormats.Emf.EmfImage)Aspose.Imaging.Image.Load(dir + "test.emf"))
                                                                                                                      {
                                                                                                                          Aspose.Imaging.ImageOptions.SvgOptions saveOptions = new Aspose.Imaging.ImageOptions.SvgOptions();

                                                                                                                          // Text will be converted to shapes.
                                                                                                                          saveOptions.TextAsShapes = true;

                                                                                                                          Aspose.Imaging.ImageOptions.EmfRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.EmfRasterizationOptions();

                                                                                                                          // The background color of the drawing surface.
                                                                                                                          rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.WhiteSmoke;

                                                                                                                          // The page size.
                                                                                                                          rasterizationOptions.PageSize = emfImage.Size;

                                                                                                                          // If embedded emf exists, then render emf; otherwise render wmf.
                                                                                                                          rasterizationOptions.RenderMode = Aspose.Imaging.FileFormats.Emf.EmfRenderMode.Auto;

                                                                                                                          // Set the horizontal margin
                                                                                                                          rasterizationOptions.BorderX = 50;

                                                                                                                          // Set the vertical margin
                                                                                                                          rasterizationOptions.BorderY = 50;

                                                                                                                          saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                          emfImage.Save(dir + "test.output.svg", saveOptions);
                                                                                                                      }

Sehen Sie auch

ImageOptionsBase

 Deutsch