PNG to PSD

Convert PNG to PSD online in Java

Portable Network Graphic (PNG) is a raster image type based on bitmap format and is widely used on websites to display high-quality digital images. This format is popular because it offers lossless compression and a much broader & brighter color palette. However, when it comes to image editing, it’s nearly impossible to edit the individual objects inside a PNG image. But, if we have a PSD file (a default Adobe Photoshop format), it’s pretty easy to edit such images. So in this article, we are going to discuss all the details on how to convert PNG to PSD on Mobile or PC using REST API.

PSD to PNG Conversion API

In order to programmatically convert one image to another image format, Aspose.Imaging Cloud SDK for Java is an amazing solution. You get the option to programmatically edit, manipulate and transform raster images, Metafiles and Photoshop files to a variety of supported formats. This single SDK is capable of converting PNG to PSD and vice versa. So with fewer code lines, you can easily perform PNG to PSD conversion.

Now, in order to get started with SDK usage, we need to add its reference in our Java project by including following information in pom.xml (maven build type project).

<repositories> 
    <repository>
        <id>aspose-cloud</id>
        <name>artifact.aspose-cloud-releases</name>
        <url>https://artifact.aspose.cloud/repo</url>
    </repository>   
</repositories>

<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-imaging-cloud</artifactId>
        <version>22.4</version>
    </dependency>
</dependencies>

If you have already registered on Aspose Cloud, please obtain your client credentials from Dashboard. Else, you need to first register a free account using a valid email address.

Convert PNG to PSD in Java

This section explains the details of how to convert PNG to PSD using Java code snippet.

  • Firstly, create an object of ImagingApi while passing your personalized client credentials.
  • Secondly, load the PNG file using readAllBytes(…) method and return value to byte[] array.
  • Thirdly, create an instance of UploadFileRequest while passing PNG name as argument and upload it to cloud storage using uploadFile(…) method.
  • Now create an object of ConvertImageRequest which takes the input PNG name and resultant format (PSD) as arguments.
  • Call the method convertImage(…) to convert the PNG to PSD format and return the output as response stream.
  • Finally, save the resultant PSD to local drive using FileOutputStream object.

The sample PNG image and PSD file used in the above example can be downloaded from PinClipart.png and Converted.psd, respectively.

png to psd

Image:- PNG to PSD conversion preview

PNG to PSD using cURL Commands

The REST APIs can easily be accessed via cURL commands (via command line terminal). So in this section, we are going to explore the details of how to perform a PNG to PSD conversion using cURL commands. Now, as a prerequisite, we need to generate a JWT access token (based on client credentials) using the following command.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now please execute the following command to convert PNG to PSD format and save the output on local drive.

curl -v -X GET "https://api.aspose.cloud/v3.0/imaging/input.png/convert?format=psd" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-o Converted.psd

Conclusion

By the end of this article, we have explored all the details of how we can convert PNG to PSD using Java REST API. Similarly, we have also explored an option to convert PNG to PSD using the cURL commands. Other than these approaches, the features of the API can easily be tested using SwaggerUI (within a web browser). Furthermore, the complete source code of the SDK is available on GitHub (published under MIT license). You may consider downloading and modifying it as per your requirements.

Nevertheless, the product documentation is an amazing source of information to learn and explore the other exciting features, being offered by the API. Lastly, in case you encounter any issues while using the API, you may consider approaching us for a quick resolution via the free product support forum.

Please visit the following links to learn more about: