原創|產品更新|編輯:李顯亮|2020-10-23 09:39:58.053|閱讀 674 次
概述:Aspose.PSD for .Net更新至新版本v20.10,支持智能對象層的渲染,支持智能對象無損轉換,歡迎下載體驗。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.PSD for .Net是高級PSD和入門級AI文件格式操作API,允許創建和編輯Photoshop文件,并提供更新圖層屬性,添加水印,執行圖形操作或將一種文件格式轉換為另一種文件的功能,沒有任何Adobe Photoshop或Adobe Illustrator依賴項。
令人興奮的是,.NET版Aspose.PSD迎來了v20.10的最新更新!新增了如下兩個新功能:
>>你可以點擊這里下載Aspose.PSD for .NET v20.10測試體驗。(安裝包僅提供部分功能,并設置限制,如需試用完整功能請)
| key | 概述 | 類別 |
|---|---|---|
| PSDNET-704 | 智能對象層的渲染 | 新功能 |
| PSDNET-707 | 支持智能對象無損轉換 | 新功能 |
| PSDNET-565 | 使用文本圖層保存特定PSD文件的例外 | Bug修復 |
| PSDNET-680 | 使用Aspose.PSD往返后,字體會丟失 | Bug修復 |
| PSDNET-711 | 保存后,文本層沒有任何變化 | Bug修復 |
| PSDNET-720 | Aspose.PSD 20.8:Psd到Tiff轉換異常 | Bug修復 |
PSDJAVA-704——智能對象層的渲染
// This example demonstrates how to replace the content of the Adobe® Photoshop® smart object layer and its correct rendering.
string dataDir = "PSDNET704_1\\";
string filePath = dataDir + "new_panama-papers-4-trans4.psd";
string pngOutputPath = dataDir + "new_panama-papers-4-trans4_replaced.png";
string psdOutputPath = dataDir + "new_panama-papers-4-trans4_replaced.psd";
string newContentPath = dataDir + "new_huset.jpg";
using (PsdImage image = (PsdImage)Image.Load(filePath))
{
var smartObjectLayer = (SmartObjectLayer)image.Layers[image.Layers.Length - 1];
smartObjectLayer.ReplaceContents(newContentPath);
image.Save(pngOutputPath, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
image.Save(psdOutputPath, new PsdOptions(image));
}
// This example demonstrates how to update the image cache of the Adobe® Photoshop® smart object layers and their correct rendering.
filePath = dataDir + "LayeredSmartObjects8bit2.psd";
pngOutputPath = dataDir + "LayeredSmartObjects8bit2_updated.png";
psdOutputPath = dataDir + "LayeredSmartObjects8bit2_updated.psd";
using (PsdImage image = (PsdImage)Image.Load(filePath))
{
image.SmartObjectProvider.UpdateAllModifiedContent();
image.Save(pngOutputPath, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
image.Save(psdOutputPath, new PsdOptions(image));
}
PSDJAVA-707——支持智能對象無損轉換
string dataDir = "PSDNET707_1\\";
string outputDir = dataDir;
// These examples demonstrate non-destructive transforms of the PSD file with SmartObjectLayer.
// We can scale, rotate, skew, distort, perspective transform, or warp a layer without
// losing original image data or quality because the transforms don’t affect the original data.
// This example demonstrates how to resize the Adobe® Photoshop® image with smart object layers:
ExampleOfSmartObjectImageResizeSupport("new_panama-papers-8-trans4-linked");
ExampleOfSmartObjectImageResizeSupport("picture-frame-4-linked3");
ExampleOfSmartObjectImageResizeSupport("gorilla");
// This example demonstrates how to resize the PSD file with smart object layers.
void ExampleOfSmartObjectImageResizeSupport(string fileName)
{
const int scale = 4;
string filePath = dataDir + fileName + ".psd";
string outputPath = outputDir + "Resize_" + fileName + ".psd";
string outputPngPath = outputDir + "Resize_" + fileName + ".png";
using (PsdImage image = (PsdImage)Image.Load(filePath))
{
int newWidth = image.Width * scale;
int newHeight = image.Height * scale;
image.Resize(newWidth, newHeight);
image.Save(outputPath, new PsdOptions(image));
image.Save(outputPngPath, new PngOptions { ColorType = PngColorType.TruecolorWithAlpha });
}
}
// This example demonstrates how to resize the Adobe® Photoshop® smart object layer.
ExampleOfSmartObjectLayerResizeSupport("new_panama-papers-8-trans4-linked");
ExampleOfSmartObjectLayerResizeSupport("gorilla");
// This example demonstrates how to resize a smart object layer in the PSD file.
void ExampleOfSmartObjectLayerResizeSupport(string fileName)
{
const double scale = 3.5;
string filePath = dataDir + fileName + ".psd";
string outputPath = outputDir + "ResizeLast_" + fileName + ".psd";
string outputPngPath = outputDir + "ResizeLast_" + fileName + ".png";
using (PsdImage image = (PsdImage)Image.Load(filePath))
{
var smartObjectLayer = image.Layers[image.Layers.Length - 1];
int newWidth = (int)(smartObjectLayer.Width * scale);
int newHeight = (int)(smartObjectLayer.Height * scale);
smartObjectLayer.Resize(newWidth, newHeight);
image.Save(outputPath, new PsdOptions(image));
image.Save(outputPngPath, new PngOptions { ColorType = PngColorType.TruecolorWithAlpha });
}
}
// This example demonstrates how to crop the Adobe® Photoshop® smart object layer.
ExampleOfSmartObjectLayerCropSupport("new_panama-papers-8-trans4-linked");
ExampleOfSmartObjectLayerCropSupport("gorilla");
// This example demonstrates how to crop a smart object layer in the PSD file.
void ExampleOfSmartObjectLayerCropSupport(string fileName)
{
string filePath = dataDir + fileName + ".psd";
string outputPath = outputDir + "CropLast_" + fileName + ".psd";
string outputPngPath = outputDir + "CropLast_" + fileName + ".png";
using (PsdImage image = (PsdImage)Image.Load(filePath))
{
var smartObjectLayer = image.Layers[image.Layers.Length - 1];
smartObjectLayer.Crop(25, 15, 30, 10);
image.Save(outputPath, new PsdOptions(image));
image.Save(outputPngPath, new PngOptions { ColorType = PngColorType.TruecolorWithAlpha });
}
}
// This example demonstrates how to crop the Adobe® Photoshop® smart object layer:
ExampleOfSmartObjectImageCropSupport("new_panama-papers-8-trans4-linked");
ExampleOfSmartObjectImageCropSupport("gorilla");
// This example demonstrates how to crop the PSD file with smart object layers.
void ExampleOfSmartObjectImageCropSupport(string fileName)
{
string filePath = dataDir + fileName + ".psd";
string outputPath = outputDir + "Crop_" + fileName + ".psd";
string outputPngPath = outputDir + "Crop_" + fileName + ".png";
using (PsdImage image = (PsdImage)Image.Load(filePath))
{
image.Crop(25, 10, 30, 5);
image.Save(outputPath, new PsdOptions(image));
image.Save(outputPngPath, new PngOptions { ColorType = PngColorType.TruecolorWithAlpha });
}
}
// This example demonstrates how to rotate and flip the Adobe® Photoshop® image with smart object layers:
ExampleOfSmartObjectImageRotateFlipSupport("gorilla", RotateFlipType.Rotate90FlipNone);
ExampleOfSmartObjectImageRotateFlipSupport("new_panama-papers-8-trans4-linked", RotateFlipType.RotateNoneFlipX);
ExampleOfSmartObjectImageRotateFlipSupport("new_panama-papers-8-trans4-linked", RotateFlipType.RotateNoneFlipY);
ExampleOfSmartObjectImageRotateFlipSupport("new_panama-papers-8-trans4-linked", RotateFlipType.RotateNoneFlipXY);
ExampleOfSmartObjectImageRotateFlipSupport("new_panama-papers-8-trans4-linked", RotateFlipType.Rotate90FlipNone);
ExampleOfSmartObjectImageRotateFlipSupport("new_panama-papers-8-trans4-linked", RotateFlipType.Rotate90FlipX);
ExampleOfSmartObjectImageRotateFlipSupport("new_panama-papers-8-trans4-linked", RotateFlipType.Rotate90FlipY);
ExampleOfSmartObjectImageRotateFlipSupport("new_panama-papers-8-trans4-linked", RotateFlipType.Rotate90FlipXY);
// This example demonstrates how to rotate and flip the PSD file with smart object layers.
void ExampleOfSmartObjectImageRotateFlipSupport(string fileName, RotateFlipType rotateFlipType)
{
string filePath = dataDir + fileName + ".psd";
string outputPath = outputDir + rotateFlipType + "_" + fileName + ".psd";
string outputPngPath = outputDir + rotateFlipType + "_" + fileName + ".png";
using (PsdImage image = (PsdImage)Image.Load(filePath))
{
image.RotateFlip(rotateFlipType);
image.Save(outputPath, new PsdOptions(image));
image.Save(outputPngPath, new PngOptions { ColorType = PngColorType.TruecolorWithAlpha });
}
}
// This example demonstrates how to rotate and flip the Adobe® Photoshop® smart object layer.
ExampleOfSmartObjectLayerRotateFlipSupport("gorilla", RotateFlipType.Rotate90FlipNone);
ExampleOfSmartObjectLayerRotateFlipSupport("r3-embedded-transform2", RotateFlipType.RotateNoneFlipX);
ExampleOfSmartObjectLayerRotateFlipSupport("r3-embedded-transform2", RotateFlipType.RotateNoneFlipY);
ExampleOfSmartObjectLayerRotateFlipSupport("r3-embedded-transform2", RotateFlipType.RotateNoneFlipXY);
ExampleOfSmartObjectLayerRotateFlipSupport("r3-embedded-transform2", RotateFlipType.Rotate90FlipNone);
ExampleOfSmartObjectLayerRotateFlipSupport("r3-embedded-transform2", RotateFlipType.Rotate90FlipX);
ExampleOfSmartObjectLayerRotateFlipSupport("r3-embedded-transform2", RotateFlipType.Rotate90FlipY);
ExampleOfSmartObjectLayerRotateFlipSupport("r3-embedded-transform2", RotateFlipType.Rotate90FlipXY);
// This example demonstrates how to rotate and flip a smart object layer in the PSD file.
void ExampleOfSmartObjectLayerRotateFlipSupport(string fileName, RotateFlipType rotateFlipType)
{
string filePath = dataDir + fileName + ".psd";
string outputPath = outputDir + rotateFlipType + "Last_" + fileName + ".psd";
string outputPngPath = outputDir + rotateFlipType + "Last_" + fileName + ".png";
using (PsdImage image = (PsdImage)Image.Load(filePath))
{
var smartObjectLayer = (SmartObjectLayer)image.Layers[image.Layers.Length - 1];
smartObjectLayer.RotateFlip(rotateFlipType);
image.Save(outputPath, new PsdOptions(image));
image.Save(outputPngPath, new PngOptions { ColorType = PngColorType.TruecolorWithAlpha });
}
}
// This example demonstrates how to rotate the Adobe® Photoshop® smart object layer by any angle:
const string AngleFormat = "+#;-#;+0";
ExampleOfSmartObjectLayerRotateSupport("gorilla", 45, false);
ExampleOfSmartObjectLayerRotateSupport("gorilla", 45, true);
ExampleOfSmartObjectLayerRotateSupport("r3-embedded-transform2", -30, true);
ExampleOfSmartObjectLayerRotateSupport("r3-embedded-transform2", -30, false);
ExampleOfSmartObjectLayerRotateSupport("new_panama-papers-8-trans4-linked", 190, false);
ExampleOfSmartObjectLayerRotateSupport("new_panama-papers-8-trans4-linked", 190, true);
// This example demonstrates how to rotate a smart object layer in the PSD file by any angle.
void ExampleOfSmartObjectLayerRotateSupport(string fileName, float angle, bool resizeProportionally)
{
string prefix = "RotateLast" + angle.ToString(AngleFormat) + (resizeProportionally ? "ResizeProportionally" : "") + "_";
string filePath = dataDir + fileName + ".psd";
string outputPath = outputDir + prefix + fileName + ".psd";
string outputPngPath = outputDir + prefix + fileName + ".png";
using (PsdImage image = (PsdImage)Image.Load(filePath))
{
var smartObjectLayer = (SmartObjectLayer)image.Layers[image.Layers.Length - 1];
smartObjectLayer.Rotate(angle, resizeProportionally, Color.Empty);
image.Save(outputPath, new PsdOptions(image));
image.Save(outputPngPath, new PngOptions { ColorType = PngColorType.TruecolorWithAlpha });
}
}
// This example demonstrates how to rotate the Adobe® Photoshop® image with smart object layer by any angle
ExampleOfSmartObjectImageRotateSupport("gorilla", 45, false);
ExampleOfSmartObjectImageRotateSupport("new_panama-papers-8-trans4-linked", -30, false);
// This example demonstrates how to rotate the PSD file with smart object layers by any angle.
void ExampleOfSmartObjectImageRotateSupport(string fileName, float angle, bool resizeProportionally)
{
string prefix = "Rotate" + angle.ToString(AngleFormat) + (resizeProportionally ? "ResizeProportionally" : "") + "_";
string filePath = dataDir + fileName + ".psd";
string outputPath = outputDir + prefix + fileName + ".psd";
string outputPngPath = outputDir + prefix + fileName + ".png";
using (PsdImage image = (PsdImage)Image.Load(filePath))
{
image.Rotate(angle, resizeProportionally, Color.Empty);
image.Save(outputPath, new PsdOptions(image));
image.Save(outputPngPath, new PngOptions { ColorType = PngColorType.TruecolorWithAlpha });
}
}
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn