PSD 图像处理器 .NET
引入 PSD 照片处理器为 .NET
PSD Photo Processor for .NET 是一個強大的圖書館,允許開發人員在他們的 .net 應用程式中處理和操縱 Photoshop 檔案(PSD)。本指南提供可用的功能概述,並解釋如何使用代碼示例完成常見任務。
加载和保存PSD文件
要开始使用 PSD 文件,您需要将其加载到您的应用程序中。
using (PsdImage image = (PsdImage)Image.Load("input.psd", new PsdLoadOptions() { LoadEffectsResource = true }))
{
// Process the image
image.Save("output.psd");
}
在此例子中,我们上传一个名为“input.psd”的PSD文件,并将其保存作为“output。
图像处理操作
PSD Photo Processor for .NET 支持各种图像处理操作,包括:
重复图像
要重定向图像,您可以使用 Resize
方法:
string sourceFile = dataDir + @"sample.psd";
string destName = dataDir + @"SimpleResizing_out.jpg";
// Load an existing image into an instance of RasterImage class
using (Image image = Image.Load(sourceFile))
{
image.Resize(800, 600);
image.Save(destName, new JpegOptions());
}
此代码将图像重新分为 800x600 像素。
旋转图像
要旋转图像,你可以使用 RotateFlip
方法:
string sourceFile = dataDir + @"sample.psd";
string destName = dataDir + @"RotatingAnImage_out.jpg";
// Load an existing image into an instance of RasterImage class
using (Image image = Image.Load(sourceFile))
{
image.RotateFlip(RotateFlipType.Rotate270FlipNone);
image.Save(destName, new JpegOptions());
}
这个代码将图像旋转为45度。
浮动图像
要点击图像,您可以使用 Flip
方法:
string sourceFile = @"sample.psd";
string destName = @"out.jpg";
// Load an image to be rotated in an instance of RasterImage
using (RasterImage image = (RasterImage)Image.Load(sourceFile))
{
image.Rotate(30f, true, Color.Green);
image.Save(destName, new JpegOptions());
}
这个代码将图像垂直滑动。