Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
C# Convert PNG or JPG Image to PSD Programmatically in .NET
string fileName = "Sample.jpg";
// Initialize PsdImage class object
PsdImage image = new PsdImage(900, 700);
// Load input image into FileStream object
Stream stream = new FileStream(fileName, FileMode.Open);
Layer layer = null;
try
{
layer = new Layer(stream);
// Add input image as layer to PSD image
image.AddLayer(layer);
}
catch (Exception e)
{
if (layer != null)
{
layer.Dispose();
}
throw e;
}
// Convert JPG image to output PSD file
image.Save("JPGtoPSD.psd");
string fileName = "Sample.png";
// Initialize PsdImage class object
PsdImage image = new PsdImage(900, 700);
// Load input image into FileStream object
Stream stream = new FileStream(fileName, FileMode.Open);
Layer layer = null;
try
{
layer = new Layer(stream);
// Add input image as layer to PSD image
image.AddLayer(layer);
}
catch (Exception e)
{
if (layer != null)
{
layer.Dispose();
}
throw e;
}
// Convert PNG image to output PSD file
image.Save("PNGtoPSD.psd");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment