public static void Run()
{
// ExStart:MergePSDlayers
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_PSD();
string sourceFileName = dataDir + "PsdImage.psd";
// Load an existing PSD file as image
using (Image image = Image.Load(sourceFileName))
{
// Convert the loaded image to PSDImage
var psdImage = (PsdImage)image;
// Create a JPG file stream
using (Stream stream = File.Create(sourceFileName.Replace("psd", "jpg")))
{
// Create JPEG option class object, Set the source property to jpg file stream and save image
var jpgOptions = new JpegOptions();
jpgOptions.Source = new StreamSource(stream);
psdImage.Save(stream, jpgOptions);
}
}
// ExEnd:MergePSDlayers
}
}