ODG file is a drawing created by Draw, a vector graphics editing application available in the Apache OpenOffice suite. It contains one or more pages that may include lines, shapes, symbols, and text. The ODG file is saved in the OASIS OpenDocument specification, which is an XML-based format. In order to open the ODG files with the open-source programs OpenOffice.org Draw and its offshoot LibreOffice Draw. However, if ODG files are converted to PSD, we can also save layers, which makes it easy to go back and edit the file later. In this article, we are going to discuss the conversion of ODG format to PSD using REST API.
Image processing API
A wide variety of image formats is available in the market and a plethora of APIs exist to process them. However, our REST-based API provides the unique capabilities to process the leading image formats including JPEG, BMP, TIFF, GIF, PNG, PSD, SVG, DjVu, DICOM, DNG, etc using a single API. Furthermore, one of the salient features of our APIs is its capabilities to handle all these formats without any 3rd party dependency. Perform all your image processing tasks using Cloud API. No additional software download or installation is required. As the APIs are developed as per REST architecture, so they can be accessed on any platform and any application type such as Desktop, Mobile, Web, or Hybrid Apps.
To further facilitate our customers, we have created wrapper SDKs around Cloud APIs so that you get all the features and capabilities in the language of your choice. In this article, we are going to discuss the capabilities of Aspose.Imaging Cloud SDK for .NET.
Installation
The first step in using the programming SDK is its installation, and it is available for download at NuGet and GitHub. So in order to install the SDK through NuGet, please execute the following command in a terminal window:
nuget install Aspose.Imaging-Cloud
Or you may consider executing the following command in the NuGet package manager:
PM> Install-Package Aspose.Imaging-Cloud
Visual Studio Installation
We can also directly add the Cloud SDK reference inside the Visual Studio solution:
- Open the Solution Explorer.
- Expand the project and Right-click Packages folder within your solution.
- Select Manage NuGet Packages… option
- Click on the Browse tab and search for “Aspose.Imaging-Cloud“.
- Click on the Aspose.Imaging-Cloud package, select the appropriate version in the right-tab and click Add Package button
Free Cloud subscription
Now, in order to maintain data integrity and privacy, we have added a security layer, so that only authorized persons can access the system. Therefore, you need to create a free subscription account by visiting Aspose.Cloud dashboard. No credit card or other payment details are required and, you can perform up to 150 Free document processing requests.
You may use your GitHub or Google account to simply Sign Up or, click on the Create a new Account button and provide the required information. Now login to the dashboard using credentials, expand the Applications section from the dashboard and scroll down towards the Client Credentials section to see Client ID and Client Secret details.
Convert ODG to PSD in C#
Please follow the steps given below to perform the conversion using C# .NET.
- Firstly, create ImagingApi object while passing Client ID and Client Secret details as arguments.
- Secondly, read the ODG image from the local drive and pass it as an argument to the UploadFileRequest object.
- Thirdly, call the UploadFile(…) method of ImagingApi to upload the file to Cloud storage.
- Now we need to create create an instance of ConvertImageRequest class which takes the image name and resultant output format as arguments.
- Then call the ConvertImage(…) method of ImagingApi class to initiate the conversion operation.
- Finally, save the output from the stream to the local drive using File.Create (the custom method is shared below).
ODG to PSD using cURL command
As mentioned earlier, the Cloud APIs are developed according to REST architecture, so they can also be accessed using the cURL commands. However, before performing the file conversion operation, please try creating a JWT access token based on your client credentials. Please execute the following cURL command to generate the JWT access token.
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=4db2f826-bf9c-42e7-8b2a-8cbca2d15553&client_secret=d757548a9f2558c39c2feebdf85b4c44" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Since we are going to use the API, it expects the input ODG file to be already available in Cloud storage. Therefore, use the following cURL command to upload the file to Cloud storage.
curl -X PUT "https://api.aspose.cloud/v3.0/imaging/storage/file/file-example_PDF.odg" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-H "Content-Type: multipart/form-data" \
-d {"File":{}}
Now that we have uploaded the ODG file to Cloud storage, please try using the following command to convert the file to PSD format.
curl -v -X GET "https://api.aspose.cloud/v3.0/imaging/file-example_PDF.odg/convert?format=PSD" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-o Converted.psd
For testing purposes, the sample ODG file used in the above example can be downloaded from file-example_PDF.odg.
Conclusion
In this article, we have discussed the features of Aspose.Imaging Cloud for popular image formats. Furthermore, we have specifically discussed the details of how we can convert ODG image files to PSD format using a C# .NET code snippet. In the subsequent section, we have discussed the details of how we can perform the same conversion using the cURL commands. Also, please note that the Cloud SDKs are developed under the MIT license, so the complete source code is available on GitHub.
In case you encounter any issues while using the API or you have any further queries, please feel free to contact us via the Free product support forum.
Related articles
We recommend visiting the following links to learn more about: