Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active April 10, 2023 02:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/5a58a43ac00fd68974d95b72d2fdb5e8 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/5a58a43ac00fd68974d95b72d2fdb5e8 to your computer and use it in GitHub Desktop.
C# Photoshop PSD to Images and PDF Conversion | Aspose.PSD for .NET

Convert PSD to Images and PDF using .NET Photoshop API

C# codes listed below demonstrating how to convert Photoshop PSD to PNG, JPEG, BMP, TIFF Images and PDF. Developers can easily use and modify these as of their PSD conversion application requirement.

More details of differnt conversion cases using .NET Photoshop Library at https://products.aspose.com/psd/net/conversion/

Here is the list of all supported formats https://docs.aspose.com/psd/net/supported-file-formats/

For code integration there few prerequisite listed in installation section below.

Installation

Install from command line as nuget install Aspose.PSD or via Package Manager Console of Visual Studio with Install-Package Aspose.PSD.

Alternatively, get the offline MSI installer or DLLs in a ZIP file from downloads.

More About .NET PSD API

Home | Product Page | Docs | Demos | API Reference | Examples | Blog | Search | Free Support | Temporary License

using (var image = new Image.Load("template.psd"))
{
var options = new BmpOptions();
image.Save("output.bmp", options);
}
using (var image = new Image.Load("template.psd"))
{
var options = new GifOptions();
image.Save("output.gif", options);
}
using (var image = new Image.Load("template.psd"))
{
var options = new Jpeg2000Options { Codec = Jpeg2000Codec.Jp2 };
image.Save("output.jp2", options);
}
using (var image = new Image.Load("template.psd"))
{
var options = new JpegOptions();
image.Save("output.jpeg", options);
}
using (var image = new Image.Load("template.psd"))
{
var options = new Jpeg2000Options();
image.Save("output.jp2", options);
}
string inputFile = dataDir + "sourceFile.psd";
using (var psdImage = (PsdImage)Image.Load(inputFile, new PsdLoadOptions()))
{
psdImage.Save(dataDir + "converted-file.pdf",
new PdfOptions() {
PdfDocumentInfo = new PdfDocumentInfo()
{
Author = "Aspose.PSD",
Keywords = "Convert,Psd,Pdf,Online,HowTo",
Subject = "PSD Conversion to PDF",
Title = "Pdf From Psd",
},
ResolutionSettings = new ResolutionSetting(5, 6)
});
}
using (var image = new Image.Load("template.psd"))
{
var options = new PngOptions();
image.Save("output.png", options);
}
using (var image = (PsdImage)Image.Load("template.psd"))
{
image.Save("output.psb", new PsdOptions() { PsdVersion = PsdVersion.Psb});
}
using (var image = new Image.Load("template.psd"))
{
var options = new TiffOptions();
image.Save("output.tiff", options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment