PSB格式轉換太麻煩?Aspose.PSD教你用代碼將大型PSB文件轉換爲PDF/JPEG格式

Aspose.PSD for .NET是高級PSD文件格式操做API,沒有任何Adobe Photoshop依賴項。API容許建立或編輯Photoshop文件,並提供更新圖層屬性,添加水印,執行圖形操做或將一種文件格式轉換爲另外一種文件的功能。spa

PSB是Adobe公司的Photoshop大型文檔文件,大小爲30,000 x 30,000像素的文件將以PSD擴展名保存,大於PSD的最大300,000 x 300,000像素的文件將以PSB擴展名保存。PSB文件支持Adobe Photoshop的圖層,效果,濾鏡和全部其餘功能。orm

儘管PSD文件是平常經常使用的Photoshop保存格式,可是在許多PSB運用也十分普遍。使用Aspose.PSD,能夠將現有PSB文件直接轉換爲PSD、PDF、JPEG和其餘幾種格式,而不會下降質量。在本文中,咱們將演示如何將PSB文件轉換爲其餘格式。文檔

同時,很高興的告訴你們,.NET版Aspose.PSD迎來了v19.12版本更新!支持連接層,支持SoCoResource,修復將PSB保存爲PNG被凍結等Bug。(點擊下載get

將PSB轉換爲JPEGstring

JpegOptions 類,可用於將PSB轉換爲JPEG。如下代碼演示了使用C#將PSB轉換爲JPEG的過程。it

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_PSB();

string[] sourceFileNames = new string[] { 
   //Test files with layers
   "Little",
   "Simple",
   //Test files without layers
   "psb",
   "psb3"
};
var options = new PsdLoadOptions();
foreach (var fileName in sourceFileNames)
{
    var sourceFileName = dataDir + fileName + ".psb";
    using (PsdImage image = (PsdImage)Image.Load(sourceFileName, options))
    {
        // All jpeg and psd files must be readable
        image.Save(dataDir + fileName + "_output.jpg", new JpegOptions() { Quality = 95 });
        image.Save(dataDir +  fileName + "_output.psb");
    }
}

將PSB轉換爲PDFio

如上所示,將PSB轉換爲PDF相似於轉換爲JPEG。該API具備PdfOptions 類,該類容許您將PSB文件導出爲PDF格式。pdf

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_PSB();

string sourceFileName = dataDir + "Simple.psb";
using (PsdImage image = (PsdImage)Image.Load(sourceFileName))
{
    string outFileName = dataDir + "Simple.pdf";
    image.Save(outFileName, new PdfOptions());
}

將PSB轉換爲PSD擴展

使用PsdOptions 類,能夠將現有的PSB文件導出爲PNG格式。如下代碼段演示瞭如何將PSB轉換爲PSD。foreach

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_PSB();

string sourceFilePathPsb = dataDir + "2layers.psb";
string outputFilePathPsd = dataDir +  "ConvertFromPsb.psd";
using (Image img = Image.Load(sourceFilePathPsb))
{
    var options = new PsdOptions((PsdImage)img) { FileFormatVersion = FileFormatVersion.Psd };
    img.Save(outputFilePathPsd, options);
}

還想要更多嗎?若是您有下載或購買需求,請隨時加入Aspose技術交流羣(642018183),咱們很高興爲您提供查詢和諮詢。

相關文章
相關標籤/搜索