convert JPG to PNG

Joint Photographic Experts Group (JPG/JPEG) and Portable Network Graphics (PNG) are two popular raster image formats being used over the internet. Unlike JPEG, which relies on DCT compression, the PNG uses LZW compression which is the same as used by GIF and TIFF formats. The biggest advantage of PNG over JPEG is that the compression is lossless, meaning there is no loss in quality each time it is opened and saved again. PNG also handles detailed, high-contrast images well. In this article, we are going to discuss the steps on how to convert JPG images to PNG format using .NET REST API.

Image processing API

Aspose.Imaging Cloud is one of our leading products for Image format processing. It enables you to crop, flip, scale, rotate, search, convert & export existing image formats to Supported File Formats. The REST architecture enables the developers to implement diverse imaging capabilities in their cloud-based solutions. In order to further facilitate our customers, we have developed Aspose.Imaging Cloud SDK for .NET on the top of Aspose.Imaging REST API so that you get all advanced image manipulation within your C# .NET applications.


In order to use the SDK, we need to first install it over the system. It’s available for download over NuGet and GitHub. Please execute the following command in the terminal to install the SDK via NuGet:

nuget install Aspose.Imaging-Cloud

Or execute the following command in NuGet Package Manager:

PM> Install-Package Aspose.Imaging-Cloud

Visual Studio approach

Another approach is the installation directly within Visual Studio:

  1. Open the Solution Explorer.
  2. Expand the project and Right-click Packages folder within your solution.
  3. Select Manage NuGet Packages… option
  4. Click on the Browse tab and search for “Aspose.Imaging-Cloud“.
  5. Click the checkbox besides Aspose.Imaging-Cloud package, select the appropriate version in the right-tab and click Add Package button.
Aspose.Imaging Cloud

Image 1:- Aspose.Imaging-Cloud as NuGet package.

Aspose.Cloud subscription

All our APIs are only accessible to authorized persons so that data integrity and privacy are maintained. Furthermore, the files stored in cloud storage are associated with the account subscribed over Aspose.Cloud dashboard. Therefore, the first step is to create a free subscription account by visiting Aspose.Cloud dashboard. If you have GitHub or Google account, simply Sign Up. Otherwise, click on the Create a new Account button and provide the required information. Now login to the dashboard using credentials and expand the Applications section from the dashboard and scroll down towards the Client Credentials section to see Client ID and Client Secret details.

Client Credentials

Image 2:- Client Credentials at Aspose.Cloud dashboard.

JPG to PNG in C#

Please follow the steps given below to perform the JPG format conversion to PNG within C# .NET application.

  • Create ImagingApi object while passing Client ID and Client Secret details as arguments
  • Secondly, read the JPEG 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 create an instance of ConvertImageRequest class which takes 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 stream to local drive using File.Create (the custom method is shared below).

cURL command for JPEG to PNG conversion

The REST architecture of Cloud APIs enables us to access them even through command line terminals. But owing to security restrictions, you need to first generate a JSON Web Token (JWT) based on ClientID and ClientSecret details retrieved from Aspose.Cloud dashboard. Please execute the following command in the terminal to generate the JWT token.

curl -v "" \
-d "grant_type=client_credentials&client_id=4ccf1790-accc-41e9-8d18-a78dbb2ed1aa&client_secret=caac6e3d4a4724b2feb53f4e460eade3" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Once we have the JWT token, the next step is to call ConvertImage API to perform the JPG to PNG conversion operation.

curl -X GET "" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-o  converted.png

Request URL


We have explored Aspose.Imaging Cloud API for the conversion of JPEG image to PNG format. We have learned the processes of converting files using C# .NET code as well as the conversion using the cURL commands. Also please note that the Cloud SDK is distributed under an MIT license and its complete source code is available for download over GitHub. In case you encounter any issue or have any query while using the API, please feel free to contact through the Free product support forum.

We also recommend visiting the following links to learn more about