PSD to JPG

Convert PSD to JPG in Java

PSD files are most commonly used by designers and artists, as the Photoshop documents are the powerful format for image data creation and storage. It’s a native format of Adobe Photoshop and can be viewed in Adobe Illustrator or Inkscape. However, a majority of users do not have such commercial applications natively installed. Also, we cannot display PSD files within web-browser. So this article, is going to explain the details on How To View PSD Files Without Photoshop On Mobile Or A PC by converting PSD to JPG online.

PSD to JPG Conversion API

Now in order to convert PSD to JPG, we are going to use Aspose.Imaging Cloud SDK for Java which enables us to implement image processing and conversion capabilities in Java application. So we can programmatically edit, manipulate and transform raster images, Metafiles & Photoshop files to a variety of Supported Formats. Now in order to get started with the SDK utilization, we need to first add its reference in our java project by including the following information in pom.xml of maven build project.

<repositories> 
    <repository>
        <id>aspose-cloud</id>
        <name>artifact.aspose-cloud-releases</name>
        <url>http://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 are already registered on Aspose Cloud Dashboard, please obtain your personalized client credentials from Cloud Dashboard. Else, register a free account using a valid email address and then obtain your credentials.

Convert PSD to JPG in Java

In this section, we are going to discuss the details on how to convert a PDF to JPG online using Java code snippet.

  • First of all, create an object of ImagingApi class by passing your personalized client credentials as arguments to its constructor
  • Secondly, read the input PSD file using readAllBytes(…) method and return the content to byte[] array
  • Thirdly, create an instance of UploadFileRequest class and then upload the PSD file to cloud storage using uploadFile(…) method
  • Now create an object of ConvertImageRequest class where we specify the input PSD name and the resultant format as “jpg”
  • Penultimate, call a method convertImage(…) to convert PSD to JPG image. The resultant image is then returned in response stream
  • Finally, save the resultant JPG to local drive using FileOutputStream object

The sample PSD image used in above example can be downloaded from FilterEffectSampleImage.psd.

psd to jpg

Image:- PSD to JPG conversion preview

Convert Photoshop to JPG using cURL Commands

As the Aspose.Imaging Cloud is developed according to REST architecture, so we can easily access the API via cURL commands via command line terminal (on any platform). Now as as a prerequisite, we need to first 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"

Once the JWT token is generated, please execute the following command to convert Photoshop to JPG format.

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

Conclusion

This article has enlightened us on the amazing feature for converting PSD to JPG using Java. At the same time, we have also explored Photoshop save as JPEG approach using the cURL commands. Furthermore, the features of the API can easily be tested using SwaggerUI (within a web browser) and the complete source code of the SDK can also be downloaded from GitHub (published under MIT license).

Nevertheless, the Product Documentation is an amazing source of information to learn other exciting features of the API. Lastly, in case you encounter any issue or you have any related query, please feel free to contact us for a quick resolution via free product support forum.

Please visit the following links to learn more about: