在这个简单的示例中,我们将详细介绍如何在 C# 中将 PSD 转换为 TIFF,具体步骤请参考搭建环境和使用示例代码的详细步骤。开发的应用程序非常简单,可用于使用易于理解的 API 接口使用 C#** 将 PSD 保存为 TIFF,并且可以在 macOS、Linux 或 Windows 内任何支持 .NET 的环境中进行配置。
在 C# 中将 PSD 转换为 TIFF 的步骤
- 通过从 NuGet 安装 Aspose.PSD for .NET 以将 PSD 导出到 TIFF 来配置开发环境
- 创建 PsdImage 类对象的实例以从磁盘打开源 PSD 文件
- 使用 TiffOptions 类的实例来设置所需的 TIFF 图像选项
- 使用 Save 方法将 PSD 转换为 TIFF 文件
通过使用 C# PSD 到 TIFF 图像转换器应用程序,可以按照上述步骤开发应用程序,该过程将通过使用 Image.Load() 方法从磁盘或内存流访问源 PSD 文件来开始。然后通过使用 Tiffptions 类的一个实例,将设置输出 TIFF 图像所需的 TIFF 属性,然后使用 Save 方法将 PSD 图像转换为磁盘上的 TIFF 图像。
在 C# 中将 PSD 导出为 TIFF 的代码
using Aspose.PSD; | |
using Aspose.PSD.FileFormats.Psd; | |
using Aspose.PSD.FileFormats.Tiff.Enums; | |
using Aspose.PSD.ImageOptions; | |
namespace TestPSD | |
{ | |
public class PsdToTiff | |
{ | |
public static void ConvertPsdToTiff() | |
{ | |
String path = @"/Users/Documents/KB/TestData/"; | |
// Applying product license to convert PSD to TIFF in C# | |
License PsdLic = new License(); | |
PsdLic.SetLicense(path + "Conholdate.Total.Product.Family.lic"); | |
using (var psdToTiffImage = (PsdImage)Image.Load(path + "Sample.psd")) | |
{ | |
// Set the output Tiff options | |
TiffOptions tiffOpts = new TiffOptions(TiffExpectedFormat.TiffLzwCmyk); | |
tiffOpts.Artist = "Aspose"; | |
tiffOpts.Compression = TiffCompressions.None; | |
tiffOpts.ImageLength = 800; | |
tiffOpts.ImageWidth = 600; | |
// Save the converted TIFF on the disk | |
psdToTiffImage.Save(path + "PsdConverted.tiff", tiffOpts); | |
} | |
} | |
} | |
} |
上面的示例演示了使用 C#* 使用简单的 API 调用将 *PSD 转换为 TIFF 的机制。 TiffOptions 类用于自定义输出 TIFF 图像属性,包括压缩、每像素位数、图像长度、图像宽度、图像分辨率和添加标签等。设置所需的 TIFF 属性后,所需的 TIFF 图像将保存在磁盘上。
在本主题中,我们重点介绍了使用 C# 将 PSD 转换为 TIFF 的步骤。如果您想探索更多并了解如何将 Adobe Illustrator (AI) 图像转换为 PNG,请参阅 如何在 C# 中将 AI 转换为 PNG 上的文章。