Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created August 1, 2024 19:17
Convert JPG to Visio Online
// This code example demonstrates how to convert a JPG image to a Visio diagram in C#
using Aspose.Diagram;
using System.Drawing;
// Create a new diagram
Diagram diagram = new Diagram();
// Get page object by index
Page page0 = diagram.Pages[0];
// Set pinX, pinY, width and height
double pinX = 2, pinY = 2, width = 4, hieght = 7;
// Import Bitmap image as Visio shape
page0.AddShape(pinX, pinY, width, hieght, new FileStream("tower.jpg", FileMode.OpenOrCreate));
// Save Visio diagram
diagram.Save("JPGtoVisio.vsdx", SaveFileFormat.Vsdx);
// This code example demonstrates how to convert a JPG image to a Visio diagram in Java
// Create a new diagram
Diagram diagram = new Diagram();
// Get page object by index
Page page0 = diagram.getPages().get(0);
// Load JPG image to insert into a Visio diagram
InputStream stream = new FileInputStream("tower.jpg");
// Import Bitmap image as Visio shape
page0.addShape(2, 2, 4, 7, stream);
// Save Visio diagram
diagram.save("JPGtoVisio.vsdx", SaveFileFormat.VSDX);
# This code sample demonstartes how to convert JPG to Visio in Python.
import aspose.diagram
from aspose.diagram import *
from PIL import Image
# Create a new diagram
diagram = Diagram();
# Get page object by index
page0 = diagram.pages[0];
# Set pinX, pinY, width and height and
# Import JPG image as Visio shape
page0.add_shape(2, 3, 4, 5, open("person.jpg", "rb"));
# Save Visio diagram
diagram.save("JPGtoVisio.vsdx", SaveFileFormat.VSDX);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment