aspose-words / Aspose.Words-for-Python-via-.NET

Aspose.Words for Python via .NET examples and showcases
MIT License
104 stars 22 forks source link

SVG image content garbled #48

Open Alduin-Y opened 8 months ago

Alduin-Y commented 8 months ago

luanma 图片 When I try to see the code inside 图片

Unable to obtain correct results using examples from the official website The code source is here: https://products.aspose.com/words/zh/python-net/conversion/image-to-svg/#codeSnippetAnchor

AlexNosk commented 8 months ago

@Alduin-Y Actually, the code you are using does not convert JPEG to SVG. ImageData.save method saves the images in the original format, so the Output.svg file will be simply a JPEG file with SVG extension. If you need to wrap your JPEG to SVG, you can use ShapeRenderer:

doc = aw.Document()
builder = aw.DocumentBuilder(doc)

shape = builder.insert_image("C:\\Temp\\in.jpg")
shape.get_shape_renderer().save("C:\\Temp\\out.svg", aw.saving.ImageSaveOptions(aw.SaveFormat.SVG))

Also, please note, there is no way to vectorize raster images using Aspose.Words.

Alduin-Y commented 8 months ago

@Alduin-Y Actually, the code you are using does not convert JPEG to SVG. ImageData.save method saves the images in the original format, so the Output.svg file will be simply a JPEG file with SVG extension. If you need to wrap your JPEG to SVG, you can use ShapeRenderer:

doc = aw.Document()
builder = aw.DocumentBuilder(doc)

shape = builder.insert_image("C:\\Temp\\in.jpg")
shape.get_shape_renderer().save("C:\\Temp\\out.svg", aw.saving.ImageSaveOptions(aw.SaveFormat.SVG))

Also, please note, there is no way to vectorize raster images using Aspose.Words.

Running successfully! thank you very much.