psd to jpg

How to convert PSD to JPG in C# .NET.

PSD files are invaluable for editing and preserving layers, but they are not always practical for sharing or displaying on the web. Also, the designers and developers collaborate on projects, and they often encounter the need to share and distribute images in a format that is universally compatible and easily accessible. Therefore, by converting PSD files to JPG format, you can ensure that your images are readily accessible across platforms and devices, without sacrificing quality or compromising design integrity. Let’s explore the importance of this conversion feature and discover how it can enhance your image processing capabilities using .NET REST API.

PSD to JPG Conversion API

Converting PSD to JPG using Aspose.Imaging Cloud SDK for .NET opens up a world of possibilities for developers and businesses alike. With this powerful SDK, you can seamlessly transform PSD files into high-quality JPG images with just a few lines of code. Beyond simple conversion, this SDK offers a wide range of advanced capabilities such as image resizing, cropping, rotation, and watermarking to customize and optimize their images according to their specific requirements.

The first step is to search Aspose.Imaging-Cloud in NuGet packages manager and click the Add Package button. This will add the SDK reference in your project. The next important step is to obtain your client credentials from cloud dashboard. If you do not have an existing account, simply create a free account by following the instructions specified in the quick start article.

Convert PSD File to JPG in C# .NET

The following section provides details on how to effortlessly change PSD to JPG using C# .NET.

ImagingApi imagingApi = new ImagingApi(clientSecret, clientID, baseUrl: "https://api.aspose.cloud");

Create an instance of ImagingApi class where we pass client credentials and baseURL as arguments.

imagingApi.UploadFile(new UploadFileRequest("input.psd", stream));

Upload the input GIF image to cloud storage.

ConvertImageRequest requestInstance = new ConvertImageRequest("input.psd", "JPG");

Create an instance of ConvertImageRequest where we specify the name of input PSD file and desired output format as JPG.

var resultant = imagingApi.ConvertImage(requestInstance);

Call the API to transfer the PSD file to JPG image and the resultant output is returned in stream instance.

saveToDisk(resultant, "myResultant.jpg");

Our custom method to save the resultant JPG image on local drive.

In another approach, we can load the input PSD file from local drive and without uploading it to the cloud storage, we can perform PSD to JPG conversion. When using this approach, the resultant JPG is also stored to the cloud storage. Please follow the instructions given below.

ImagingApi imagingApi = new ImagingApi(clientSecret, clientID, baseUrl: "https://api.aspose.cloud");

Create an instance of ImagingApi class where we pass client credentials and baseURL as arguments.

CreateConvertedImageRequest requestInstance = new CreateConvertedImageRequest(imageStream, "jpeg", "Resultant.jpeg");

Create an instance of CreateConvertedImageRequest class where we pass the stream containing PSD image, output format as JPEG and name of resultant JPG.

var resultant = imagingApi.CreateConvertedImage(requestInstance);

Call the API to convert PSD to JPG format. Once the conversion is completed successfully, the resultant image is stored in cloud storage.

psd to jpg conversion

A preview of PSD to JPG conversion.

The sample PSD used in above example can be downloaded from FilterEffectSampleImage.psd and the resultant JPG from myResultant.jpg.

Change PSD to JPG using cURL Commands

By integrating Aspose.Imaging Cloud with cURL commands, you can automate the conversion process and incorporate it into your existing scripts or applications with ease. With just a few simple commands, you can initiate the conversion, specify the input PSD file, and receive the resulting JPG output. This approach not only simplifies the process of converting PSD to JPG but also enhances flexibility and scalability.

The first step in this approach is to generate a JWT access token using the following command:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=163c02a1-fcaa-4f79-be54-33012487e783&client_secret=c71cfe618cc6c0944f8f96bdef9813ac" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Now that we have JWT token, please execute the following command to develop a PSD viewer, as we can simply convert PSD to JPG image. Once the command is successfully executed, the resultant JPG image is stored on local drive.

curl -v "https://api.aspose.cloud/v3.0/imaging/{sourceFile}/convert?format=jpeg" \
-X GET \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-o "converted.jpg"

Replace sourceFile with the name of input PSD file already available in cloud storage, and accessToken with JWT access token.

Conclusion

In conclusion, the conversion of PSD to JPG is made efficient and versatile through both approaches: utilizing Aspose.Imaging Cloud SDK for .NET and integrating Aspose.Imaging Cloud with cURL commands. By leveraging the capabilities of Aspose.Imaging Cloud SDK for .NET, developers can benefit from a wide range of advanced features, including image resizing, cropping, rotation, and watermarking, all accessible through an intuitive API. Nonetheless, the REST API remains a trusted and efficient tool for converting PSD to JPG, empowering you to streamline your image processing tasks and optimize the workflows with ease.

We highly recommend visiting the following blog posts for information on: