Class SvgOptions

Class SvgOptions

De naam: Aspose.Imaging.ImageOptions Verzameling: Aspose.Imaging.dll (25.4.0)

Creëer Scalar Vector Graphics (SVG) beeldbestanden met onze API, met behulp van versatiliteitopties voor kleurstypen en compressie niveaus. Onmiddellijk aanpassen van uwSVG afbeeldingen met nauwkeurigheid, zorgen voor optimale kwaliteit en compatibiliteit voor uw ontwerpbehoeften.

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

Inheritance

object DisposableObject ImageOptionsBase SvgOptions

Implements

IDisposable , IHasXmpData , IHasMetadata , ICloneable

Geëerbiede leden

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

Het volgende voorbeeld laat zien hoe je een svgz-afbeelding kunt converteren naar svG fromat

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

Het volgende voorbeeld laat zien hoe je een svg-afbeelding kunt converteren naar svGz fromat

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

Het volgende voorbeeld toont hoe je een multipage vector-afbeelding in het SVG-formaat over het algemeen kunt converteren zonder verwijzing naar een specifiek beeldtype.

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

Geeft of stelt de opslagstrategie voor ingebouwde resussies van Aspose.Imaging.FileFormats.Svg.VvGImage zoals fonts, nested rasters.

public ISvgResourceKeeperCallback Callback { get; set; }

Eigendomswaarde

ISvgResourceKeeperCallback

ColorType

Geeft of stelt de kleurtype voor SVG-afbeelding.

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

Eigendomswaarde

SvgColorMode

Compress

Geeft of stelt een waarde aan die aanwijst of het uitgangsbeeld moet worden gecomprimeerd.

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

Eigendomswaarde

bool

Examples

Het volgende voorbeeld laat zien hoe je een svg-afbeelding kunt converteren naar svGz fromat

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

Geeft of stelt een waarde aan die aanwijst of tekst moet worden gepresenteerd als vormen.

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

Eigendomswaarde

bool

Examples

Dit voorbeeld laat zien hoe u een WMF-afbeelding van een bestand kunt laden en deze naar SVG kunt converteren met behulp van WmfRasterizationOptions.

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

Dit voorbeeld laat zien hoe u een EMF-afbeelding van een bestand kunt laden en deze naar SVG kunt converteren met behulp van EmfRasterizationOptions.

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

Zie ook

ImageOptionsBase

 Nederlands