svg to jpg

Online SVG to JPG Conversion in C# .NET.

SVG (Scalable Vector Graphics) files are excellent for web graphics due to their scalability and resolution independence. However, there are times when converting SVG to JPG (Joint Photographic Experts Group) is necessary, particularly for compatibility with platforms and applications that do not support SVG. In this article, we are going to explain the details on how to perform SVG to JPG conversion using GroupDocs.Conversion Cloud SDK for .NET. This method not only simplifies the process but also ensures high-quality results, making it an invaluable tool for developers.

SVG to JPG Conversion SDK

GroupDocs.Conversion Cloud SDK for .NET is a powerful SDK designed to simplify and streamline the process of converting various document and image formats (over 50 file types). The SDK handles the intricate details of the conversion process, ensuring high-quality output and preserving the integrity of the original image.

The first step is to install the SDK by searching GroupDocs.Conversion-Cloud in NuGet package manager and then, click the Install button. Alternatively, you may consider executing the following command in package manager console.

NuGet\Install-Package GroupDocs.Conversion-Cloud -Version 24.4.0

After installation, we need to obtain our personalized API credentials(i.e. Client ID and Client Secret). Please follow the instructions specified in this short tutorial explaining the details on how to get the API credentials.

Convert SVG to JPG in C# .NET

This section is going to shed light on the flexibility of GroupDocs.Conversion Cloud SDK which makes it an ideal choice for developers seeking a reliable and efficient scalable vector graphics to JPG conversion within .NET applications.

  1. Create an instance of Configuration class where we pass client credentials as arguments.
var configurations = new Configuration(clientId, clientSecret1);
  1. Initialize the ConvertApi where we pass Configuration object as an input argument.
var apiInstance = new ConvertApi(configurations);
  1. Upload the input SVG image to the cloud storage.
fileUpload.UploadFile(new UploadFileRequest("input.svg", stream));
  1. Create an instance of ConvertSettings where we specify the name of input SVG file, resultant format as jpg and the name of the resultant JPEG Image as arguments.
var settings = new ConvertSettings{...}
  1. Call the ConvertDocumentRequest API to transform the SVG to JPG format and save the resultant JPG to the cloud storage.
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));

The sample SVG image used in the above example can be downloaded from trashloader.svg.

SVG to JPG Conversion using cURL Commands

Converting SVG to JPG using GroupDocs.Conversion Cloud API and cURL commands is a straightforward process that allows you to leverage the powerful features of the GroupDocs platform through simple HTTP requests. This method provides a quick and efficient way to perform image conversions programmatically, making it ideal for automating tasks in various development environments.

In this approach, first we need to generate the JWT access token based on client credentials. Once the JWT token is obtained, please execute the following cURL command to convert the scalable vector graphics to JPG raster image. After conversion, the resultant JPEG is stored in the cloud storage.

curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{  \"StorageName\": \"default\",  \"FilePath\": \"{sourceSVG}\",  \"Format\": \"jpg\",  \"OutputPath\": \"{resultantFile}\"}"

Please replace sourceSVG with the name of input scalable vector graphics image, resultantFile with the name of resultant JPG image and accessToken with a personalized JWT access token.

  • Now instead of saving the resultant JPG to cloud storage, we can also save the resultant file on local drive using the following cURL command:
curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H  "Content-Type: application/json" \
-d "{  \"StorageName\": \"default\",  \"FilePath\": \"{sourceFile}\",  \"Format\": \"jpg\"}" \
-o "myResultant.jpg"

Free SVG to JPG Converter

We highly recommend you to try using our free, lightweight and supper-efficient SVG to JPG Conversion App, developed using GroupDocs.Conversion Cloud APIs. You can experience the amazing capabilities of SVG to JPG conversion without any installation.

svg to jpg converter

Conclusion

In summary, the conversion of SVG to JPG can be efficiently achieved using the GroupDocs.Conversion Cloud SDK for .NET or through cURL commands. We have learned that the SDK provides a seamless integration with C# .NET applications, offering robust capabilities and customization options for high-quality conversions. Alternatively, cURL commands offer a straightforward way to interact with the GroupDocs API for quick and automated image processing. Nevertheless, both methods ensure reliable and professional results, making GroupDocs.Conversion an excellent choice for all your image conversion needs.

We also recommend visiting the following links to learn more about: