Chuyển Đổi Hình Ảnh PSD Sang Định Dạng Raster Sử Dụng C#

Tổng Quan

Aspose.PSD cho phép chuyển đổi các định dạng PSD và PSB sang JPEG, JPEG2000, PNG, TIFF, PDF, GIF và BMP

Bạn có thể chuyển đổi các tệp PSD trên máy chủ của mình với Aspose.PSD mà không cần Photoshop. Đó là một sự thay thế tốt cho việc viết script của Adobe Photoshop vì EULA của Adobe cấm việc sử dụng ứng dụng trên một máy chủ và thay đổi giao diện người dùng của nó. Nhưng với SDK định dạng PSD, bạn có thể tạo một chuyển đổi hàng loạt của các Tệp PSD. Việc xuất định dạng PSD của bạn có thể hoàn hảo với chế độ Chỉ Đọc, hoặc bạn có thể thay đổi lớp, văn bản, hiệu ứng, và sau đó làm xuất.

Các Ví Dụ Cụ Thể Của Chuyển Đổi PSD Sang Định Dạng Raster

Xuất Hình Ảnh PSD Sang Các Định Dạng Tập Tin Raster Khác Nhau

Mã mẫu dưới đây minh họa cách chuyển đổi PSD sang một số định dạng tập tin raster khác nhau.

// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET
string srcPath = dataDir + @"sample.psd";
string destName = dataDir + @"export";
// Load an existing PSD image as Image
using (Image image = Image.Load(srcPath))
{
// Create an instance of PngOptions class
PngOptions pngOptions = new PngOptions();
// Create an instance of BmpOptions class
BmpOptions bmpOptions = new BmpOptions();
// Create an instance of TiffOptions class
TiffOptions tiffOptions = new TiffOptions(FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
// Create an instance of GifOptions class
GifOptions gifOptions = new GifOptions();
// Create an instance of JpegOptions class
JpegOptions jpegOptions = new JpegOptions();
// Create an instance of Jpeg2000Options class
Jpeg2000Options jpeg2000Options = new Jpeg2000Options();
// Call the save method, provide output path and export options to convert PSD file to various raster file formats.
image.Save(destName + ".png", pngOptions);
image.Save(destName + ".bmp", bmpOptions);
image.Save(destName + ".tiff", tiffOptions);
image.Save(destName + ".gif", gifOptions);
image.Save(destName + ".jpeg", jpegOptions);
image.Save(destName + ".jp2", jpeg2000Options);
}