原創|產品更新|編輯:李顯亮|2020-02-28 13:14:29.577|閱讀 293 次
概述:Aspose.PSD for .Net是高級PSD和入門級AI文件格式操作API,允許創建和編輯Photoshop文件,令人興奮的是,.NET版Aspose.PSD迎來了2月的最新更新!新增了六大新功能,歡迎下載體驗。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.PSD for .Net是高級PSD和入門級AI文件格式操作API,允許創建和編輯Photoshop文件,并提供更新圖層屬性,添加水印,執行圖形操作或將一種文件格式轉換為另一種文件的功能,沒有任何Adobe Photoshop或Adobe Illustrator依賴項。
令人興奮的是,.NET版Aspose.PSD迎來了2月的最新更新!新增了如下六大新功能:
>>你可以點擊這里下載Aspose.PSD for .NET v20.2測試體驗
key | 概述 | 類別 |
---|---|---|
PSDNET-206 | 改進了在“文本層”中呈現不同顏色的文本的能力 | 新功能 |
PSDNET-369 | 支持clbl資源(層資源包含有關Blend裁剪元素的信息) | 新功能 |
PSDNET-274 | 支持blwh資源(資源包含黑白調整層數據) | 新功能 |
PSDNET-230 | 能夠將圖層組導出到Jpeg / Png / Tiff / Gif / Bmp / Jpeg2000 / Psd / Psb / Pdf | 新功能 |
PSDNET-372 | 支持lspf資源(包含有關“受保護的層”設置的設置) | 新功能 |
PSDNET-370 | 支持infx資源(包含有關內部元素混合的數據) | 新功能 |
PSDNET-251 | 重構PsdImage和Layer以更改轉換行為(如果我們分別轉換一層,則正確調整圖層蒙版的大小/旋轉/裁剪) | 增強功能 |
PSDNET-276 | 在某些全球化設置中,無法打開AI Image光柵圖像 |
Bug修復 |
PSDNET-194 | 在圖層上執行FlipRotate操作后,PSD圖像變得不可讀 |
Bug修復 |
PSDNET-177 | 加載PSD文件時出現System.ArgumentException |
Bug修復 |
PSDNET-249 | 僅對圖層使用轉換方法后,保存的圖層的邊界或蒙版不正確 |
Bug修復 |
using (var psdImage = (PsdImage)Image.Load("text_ethalon_different_colors.psd")) { var txtLayer = (TextLayer)psdImage.Layers[1]; txtLayer.TextData.UpdateLayerData(); psdImage.Save("output.png", new PngOptions()); }
void AssertIsTrue(bool condition, string message) { if (!condition) { throw new FormatException(message); } } string sourceFileName = "SampleForResource.psd"; string destinationFileName = "Output" + sourceFileName; ClblResource GetClblResource(PsdImage im) { foreach (var layer in im.Layers) { foreach (var layerResource in layer.Resources) { if (layerResource is ClblResource) { return (ClblResource)layerResource; } } } throw new Exception("The specified ClblResource not found"); } using (PsdImage im = (PsdImage)Image.Load(sourceFileName)) { var resource = GetClblResource(im); AssertIsTrue(resource.BlendClippedElements, "The ClblResource.BlendClippedElements should be true"); // Test editing and saving resource.BlendClippedElements = false; im.Save(destinationFileName); } using (PsdImage im = (PsdImage)Image.Load(destinationFileName)) { var resource = GetClblResource(im); AssertIsTrue(!resource.BlendClippedElements, "The ClblResource.BlendClippedElements should change to false"); }
const string ActualPropertyValueIsWrongMessage = "Expected property value is not equal to actual value"; void AssertIsTrue(bool condition, string message) { if (!condition) { throw new FormatException(message); } } void ExampleSupportOfBlwhResource( string sourceFileName, int reds, int yellows, int greens, int cyans, int blues, int magentas, bool useTint, int bwPresetKind, string bwPresetFileName, double tintColorRed, double tintColorGreen, double tintColorBlue, int tintColor, int newTintColor) { string destinationFileName = "Output" + sourceFileName; bool isRequiredResourceFound = false; using (PsdImage im = (PsdImage)Image.Load(sourceFileName)) { foreach (var layer in im.Layers) { foreach (var layerResource in layer.Resources) { if (layerResource is BlwhResource) { var blwhResource = (BlwhResource)layerResource; var blwhLayer = (BlackWhiteAdjustmentLayer)layer; isRequiredResourceFound = true; AssertIsTrue(blwhResource.Reds == reds, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Yellows == yellows, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Greens == greens, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Cyans == cyans, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Blues == blues, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Magentas == magentas, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.UseTint == useTint, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.TintColor == tintColor, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.BwPresetKind == bwPresetKind, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.BlackAndWhitePresetFileName == bwPresetFileName, ActualPropertyValueIsWrongMessage); AssertIsTrue(Math.Abs(blwhLayer.TintColorRed - tintColorRed) < 1e-6, ActualPropertyValueIsWrongMessage); AssertIsTrue(Math.Abs(blwhLayer.TintColorGreen - tintColorGreen) < 1e-6, ActualPropertyValueIsWrongMessage); AssertIsTrue(Math.Abs(blwhLayer.TintColorBlue - tintColorBlue) < 1e-6, ActualPropertyValueIsWrongMessage); // Test editing and saving blwhResource.Reds = reds - 15; blwhResource.Yellows = yellows - 15; blwhResource.Greens = greens + 15; blwhResource.Cyans = cyans + 15; blwhResource.Blues = blues - 15; blwhResource.Magentas = magentas - 15; blwhResource.UseTint = !useTint; blwhResource.BwPresetKind = 4; blwhResource.BlackAndWhitePresetFileName = "bwPresetFileName"; blwhLayer.TintColorRed = tintColorRed - 60; blwhLayer.TintColorGreen = tintColorGreen - 60; blwhLayer.TintColorBlue = tintColorBlue - 60; im.Save(destinationFileName); break; } } } } AssertIsTrue(isRequiredResourceFound, "The specified BlwhResource not found"); isRequiredResourceFound = false; using (PsdImage im = (PsdImage)Image.Load(destinationFileName)) { foreach (var layer in im.Layers) { foreach (var layerResource in layer.Resources) { if (layerResource is BlwhResource) { var blwhResource = (BlwhResource)layerResource; var blwhLayer = (BlackWhiteAdjustmentLayer)layer; isRequiredResourceFound = true; AssertIsTrue(blwhResource.Reds == reds - 15, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Yellows == yellows - 15, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Greens == greens + 15, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Cyans == cyans + 15, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Blues == blues - 15, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Magentas == magentas - 15, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.UseTint == !useTint, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.TintColor == newTintColor, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.BwPresetKind == 4, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.BlackAndWhitePresetFileName == "bwPresetFileName", ActualPropertyValueIsWrongMessage); AssertIsTrue(Math.Abs(blwhLayer.TintColorRed - tintColorRed + 60) < 1e-6, ActualPropertyValueIsWrongMessage); AssertIsTrue(Math.Abs(blwhLayer.TintColorGreen - tintColorGreen + 60) < 1e-6, ActualPropertyValueIsWrongMessage); AssertIsTrue(Math.Abs(blwhLayer.TintColorBlue - tintColorBlue + 60) < 1e-6, ActualPropertyValueIsWrongMessage); break; } } } } AssertIsTrue(isRequiredResourceFound, "The specified BlwhResource not found"); } ExampleSupportOfBlwhResource( "BlackWhiteAdjustmentLayerStripesMask.psd", 0x28, 0x3c, 0x28, 0x3c, 0x14, 0x50, false, 1, "\0", 225.00045776367188, 211.00067138671875, 179.00115966796875, -1977421, -5925001); ExampleSupportOfBlwhResource( "BlackWhiteAdjustmentLayerStripesMask2.psd", 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, true, 4, "\0", 239.996337890625, 127.998046875, 63.9990234375, -1015744, -4963324); Console.WriteLine("BlwhResource updating works as expected. Press any key.");
using (var psdImage = (PsdImage)Image.Load("1.psd")) { // folder with background LayerGroup bg_folder = (LayerGroup)psdImage.Layers[0]; // folder with content LayerGroup content_folder = (LayerGroup)psdImage.Layers[4]; bg_folder.Save("background.png", new PngOptions()); content_folder.Save("content.png", new PngOptions()); }
const string ActualPropertyValueIsWrongMessage = "Expected property value is not equal to actual value"; void AssertIsTrue(bool condition, string message) { if (!condition) { throw new FormatException(message); } } string sourceFileName = "SampleForResource.psd"; string destinationFileName = "Output" + sourceFileName; bool isRequiredResourceFound = false; using (PsdImage im = (PsdImage)Image.Load(sourceFileName)) { foreach (var layer in im.Layers) { foreach (var layerResource in layer.Resources) { if (layerResource is LspfResource) { var resource = (LspfResource)layerResource; isRequiredResourceFound = true; AssertIsTrue(false == resource.IsCompositeProtected, ActualPropertyValueIsWrongMessage); AssertIsTrue(false == resource.IsPositionProtected, ActualPropertyValueIsWrongMessage); AssertIsTrue(false == resource.IsTransparencyProtected, ActualPropertyValueIsWrongMessage); // Test editing and saving resource.IsCompositeProtected = true; AssertIsTrue(true == resource.IsCompositeProtected, ActualPropertyValueIsWrongMessage); AssertIsTrue(false == resource.IsPositionProtected, ActualPropertyValueIsWrongMessage); AssertIsTrue(false == resource.IsTransparencyProtected, ActualPropertyValueIsWrongMessage); resource.IsCompositeProtected = false; resource.IsPositionProtected = true; AssertIsTrue(false == resource.IsCompositeProtected, ActualPropertyValueIsWrongMessage); AssertIsTrue(true == resource.IsPositionProtected, ActualPropertyValueIsWrongMessage); AssertIsTrue(false == resource.IsTransparencyProtected, ActualPropertyValueIsWrongMessage); resource.IsPositionProtected = false; resource.IsTransparencyProtected = true; AssertIsTrue(false == resource.IsCompositeProtected, ActualPropertyValueIsWrongMessage); AssertIsTrue(false == resource.IsPositionProtected, ActualPropertyValueIsWrongMessage); AssertIsTrue(true == resource.IsTransparencyProtected, ActualPropertyValueIsWrongMessage); resource.IsCompositeProtected = true; resource.IsPositionProtected = true; resource.IsTransparencyProtected = true; im.Save(destinationFileName); break; } } } } AssertIsTrue(isRequiredResourceFound, "The specified LspfResource not found"); isRequiredResourceFound = false; using (PsdImage im = (PsdImage)Image.Load(destinationFileName)) { foreach (var layer in im.Layers) { foreach (var layerResource in layer.Resources) { if (layerResource is LspfResource) { var resource = (LspfResource)layerResource; isRequiredResourceFound = true; AssertIsTrue(resource.IsCompositeProtected, ActualPropertyValueIsWrongMessage); AssertIsTrue(resource.IsPositionProtected, ActualPropertyValueIsWrongMessage); AssertIsTrue(resource.IsTransparencyProtected, ActualPropertyValueIsWrongMessage); break; } } } } AssertIsTrue(isRequiredResourceFound, "The specified LspfResource not found"); Console.WriteLine("LspfResource updating works as expected. Press any key.");
void AssertIsTrue(bool condition, string message) { if (!condition) { throw new FormatException(message); } } string sourceFileName = "SampleForResource.psd"; string destinationFileName = "Output" + sourceFileName; bool isRequiredResourceFound = false; using (PsdImage im = (PsdImage)Image.Load(sourceFileName)) { foreach (var layer in im.Layers) { foreach (var layerResource in layer.Resources) { if (layerResource is InfxResource) { var resource = (InfxResource)layerResource; isRequiredResourceFound = true; AssertIsTrue(!resource.BlendInteriorElements, "The InfxResource.BlendInteriorElements should be false"); // Test editing and saving resource.BlendInteriorElements = true; im.Save(destinationFileName); break; } } } } AssertIsTrue(isRequiredResourceFound, "The specified InfxResource not found"); isRequiredResourceFound = false; using (PsdImage im = (PsdImage)Image.Load(destinationFileName)) { foreach (var layer in im.Layers) { foreach (var layerResource in layer.Resources) { if (layerResource is InfxResource) { var resource = (InfxResource)layerResource; isRequiredResourceFound = true; AssertIsTrue(resource.BlendInteriorElements, "The InfxResource.BlendInteriorElements should change to true"); break; } } } } AssertIsTrue(isRequiredResourceFound, "The specified InfxResource not found");
var enums = (RotateFlipType[])Enum.GetValues(typeof(RotateFlipType)); var fileNames = new string[] { "OneRegularAndOneAdjustmentWithVectorAndLayerMask", "OneRegularAndOneAdjustmentWithLayerMask", "TextLayer", "LinkedShapesWithText" }; foreach (string fileName in fileNames) { foreach (RotateFlipType rotateFlipType in enums) { string sourceFileName = fileName + ".psd"; string destinationFileName = fileName + "_" + rotateFlipType; var psdLoadOptions = new PsdLoadOptions() { LoadEffectsResource = true }; using (PsdImage image = (PsdImage)Image.Load(sourceFileName, psdLoadOptions)) { image.RotateFlip(rotateFlipType); image.Save(destinationFileName); } } }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn