Catatan Rilis Aspose.PSD untuk Java 20.7

Contents
[ ]
Kunci Ringkasan Kategori
PSDJAVA-231 Dukungan penambahan Efek Stroke saat runtime Fitur
PSDJAVA-249 Dukungan untuk Sumber Daya lnk2 / lnk3 (Sumber Daya Lapisan Objek Pintar) Fitur
PSDJAVA-247 Perubahan Pesan Exception saat mencoba membuka format yang tidak didukung sebagai gambar Peningkatan
PSDJAVA-235 Jika kita menyimpan file PSD setelah membuat Grup Layer baru, kita akan mendapatkan peringatan Photoshop saat membuka file. Bug
PSDJAVA-236 Gagal menyimpan LayerMask Bug
PSDJAVA-237 Clipping mask tidak berlaku untuk folder Bug
PSDJAVA-238 Tidak dapat membuka file dengan Aspose.PSD untuk Java Bug
PSDJAVA-239 Pengecualian kegagalan penyimpanan gambar saat mengonversi PSD ke PDF Bug
PSDJAVA-240 Operasi Cropping membuat jalur Clipping tidak valid pada gambar PSD Bug
PSDJAVA-241 NullReference Exception saat mencoba menyimpan File PSD tertentu dengan Efek Bayangan Bug
PSDJAVA-243 Aspose.PSD mengembalikan nilai true pada Image.CanLoad(pdfStream) Bug
PSDJAVA-244 Layer gagal dirender dalam PNG yang dihasilkan Bug
PSDJAVA-245 Pengecualian saat mengakses TextData Bug
PSDJAVA-246 ImageSaveException saat menyimpan file PSD Bug

Perubahan API Publik

API Ditambahkan:

  • F:com.aspose.psd.fileformats.psd.layers.layereffects.StrokePosition.Center
  • F:com.aspose.psd.fileformats.psd.layers.layereffects.StrokePosition.Inside
  • F:com.aspose.psd.fileformats.psd.layers.layereffects.StrokePosition.Outside
  • F:com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.Lnk3Resource.TypeToolKey
  • M:com.aspose.psd.fileformats.psd.PsdImage.addExposureAdjustmentLayer
  • M:com.aspose.psd.fileformats.psd.layers.layereffects.BlendingOptions.addStroke(int)
  • M:com.aspose.psd.fileformats.psd.layers.layereffects.StrokeEffect.getOverprint
  • M:com.aspose.psd.fileformats.psd.layers.layereffects.StrokeEffect.getPosition
  • M:com.aspose.psd.fileformats.psd.layers.layereffects.StrokeEffect.getSize
  • M:com.aspose.psd.fileformats.psd.layers.layereffects.StrokeEffect.setOverprint(boolean)
  • M:com.aspose.psd.fileformats.psd.layers.layereffects.StrokeEffect.setPosition(short)
  • M:com.aspose.psd.fileformats.psd.layers.layereffects.StrokeEffect.setSize(int)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.LiFdDataSource.getData
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.LiFdDataSource.setData(byte[])
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.Lnk2Resource.#ctor
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.Lnk2Resource.get_Item(int)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.Lnk3Resource.#ctor
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.Lnk3Resource.getKey
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.IVectorPathData.getPaths
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.IVectorPathData.getVersion
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.IVectorPathData.isDisabled
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.IVectorPathData.isInverted
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.IVectorPathData.isNotLinked
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.IVectorPathData.setDisabled(boolean)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.IVectorPathData.setInverted(boolean)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.IVectorPathData.setNotLinked(boolean)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.IVectorPathData.setPaths(com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathRecord[])
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.IVectorPathData.setVersion(int)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.#ctor
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.#ctor(byte[])
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.getLength
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.getPaths
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.getVersion
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.isDisabled
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.isInverted
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.isNotLinked
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.setDisabled(boolean)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.setInverted(boolean)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.setNotLinked(boolean)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.setPaths(com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathRecord[])
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData.setVersion(int)
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.#ctor(byte[])
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.getDataSize
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.getMinimalVersion
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.getPaths
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.getVersion
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.isDisabled
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.isInverted
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.isNotLinked
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.saveData(com.aspose.psd.StreamContainer)
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.setDisabled(boolean)
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.setInverted(boolean)
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.setNotLinked(boolean)
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.setPaths(com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathRecord[])
  • M:com.aspose.psd.fileformats.psd.resources.WorkingPathResource.setVersion(int)
  • T:com.aspose.psd.fileformats.psd.layers.layereffects.StrokePosition
  • T:com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.Lnk3Resource
  • T:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.IVectorPathData
  • T:com.aspose.psd.fileformats.psd.layers.layerresources.vectorpaths.VectorPathData
  • T:com.aspose.psd.fileformats.psd.resources.WorkingPathResource

API Dihapus:

  • F:com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.LinkDataSource.DescriptorVersion
  • F:com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.LinkDataSource.UnexpectedLinkResourceTypeValue
  • F:com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.LinkDataSource.ZeroChar
  • M:com.aspose.psd.fileformats.psd.PsdImage.addExposureLayer(float,float,float)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.Lnk2Resource.#ctor(com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.LinkDataSource[])

Contoh Penggunaan:

PSDJAVA-231. Dukungan penambahan Efek Stroke saat runtime

// Contoh ini menunjukkan bagaimana menambahkan efek stroke (pinggiran) ke layer yang sudah ada di file PSD menggunakan Java.
// Ada tiga jenis stroke: warna, gradien, dan pola. Setiap jenis memiliki
// tiga cara (posisi) di mana stroke dirender: di dalam, pusat, dan luar.
// Contoh ini menunjukkan penggunaan semua kasus tersebut.
 
String srcPsdPath = "StrokeEffectsSource.psd";
String dstPngPath = "output.png";
 
PsdLoadOptions psdLoadOptions = new PsdLoadOptions();
psdLoadOptions.setLoadEffectsResource(true);
PsdImage psdImage = (PsdImage)Image.load(srcPsdPath, psdLoadOptions);
try
{
    StrokeEffect strokeEffect;
    IColorFillSettings colorFillSettings;
    IGradientFillSettings gradientFillSettings;
    IPatternFillSettings patternFillSettings;
 
    // 1. Menambahkan isi Warna, di posisi di dalam
    strokeEffect = psdImage.getLayers()[1].getBlendingOptions().addStroke(FillType.Color);
    strokeEffect.setSize(7);
    strokeEffect.setPosition(StrokePosition.Inside);
    colorFillSettings = (IColorFillSettings)strokeEffect.getFillSettings();
    colorFillSettings.setColor(Color.getGreen());
 
    // 2. Menambahkan isi Warna, di posisi luar
    strokeEffect = psdImage.getLayers()[2].getBlendingOptions().addStroke(FillType.Color);
    strokeEffect.setSize(7);
    strokeEffect.setPosition(StrokePosition.Outside);
    colorFillSettings = (IColorFillSettings)strokeEffect.getFillSettings();
    colorFillSettings.setColor(Color.getGreen());
 
    // 3. Menambahkan isi Warna, di posisi tengah
    strokeEffect = psdImage.getLayers()[3].getBlendingOptions().addStroke(FillType.Color);
    strokeEffect.setSize(7);
    strokeEffect.setPosition(StrokePosition.Center);
    colorFillSettings = (IColorFillSettings)strokeEffect.getFillSettings();
    colorFillSettings.setColor(Color.getGreen());
 
    // 4. Menambahkan isi Gradien, di posisi di dalam
    strokeEffect = psdImage.getLayers()[4].getBlendingOptions().addStroke(FillType.Gradient);
    strokeEffect.setSize(5);
    strokeEffect.setPosition(StrokePosition.Inside);
    gradientFillSettings = (IGradientFillSettings)strokeEffect.getFillSettings();
    gradientFillSettings.setAlignWithLayer(false);
    gradientFillSettings.setAngle(90);
 
    // 5. Menambahkan isi Gradien, di posisi luar
    strokeEffect = psdImage.getLayers()[5].getBlendingOptions().addStroke(FillType.Gradient);
    strokeEffect.setSize(5);
    strokeEffect.setPosition(StrokePosition.Outside);
    gradientFillSettings = (IGradientFillSettings)strokeEffect.getFillSettings();
    gradientFillSettings.setAlignWithLayer(true);
    gradientFillSettings.setAngle(90);
 
    // 6. Menambahkan isi Gradien, di posisi tengah
    strokeEffect = psdImage.getLayers()[6].getBlendingOptions().addStroke(FillType.Gradient);
    strokeEffect.setSize(5);
    strokeEffect.setPosition(StrokePosition.Center);
    gradientFillSettings = (IGradientFillSettings)strokeEffect.getFillSettings();
    gradientFillSettings.setAlignWithLayer(true);
    gradientFillSettings.setAngle(0);
 
    // 7. Menambahkan isi Pola, di posisi di dalam
    strokeEffect = psdImage.getLayers()[7].getBlendingOptions().addStroke(FillType.Pattern);
    strokeEffect.setSize(5);
    strokeEffect.setPosition(StrokePosition.Inside);
    patternFillSettings = (IPatternFillSettings)strokeEffect.getFillSettings();
    patternFillSettings.setScale(200);
 
    // 8. Menambahkan isi Pola, di posisi luar
    strokeEffect = psdImage.getLayers()[8].getBlendingOptions().addStroke(FillType.Pattern);
    strokeEffect.setSize(10);
    strokeEffect.setPosition(StrokePosition.Outside);
    patternFillSettings = (IPatternFillSettings)strokeEffect.getFillSettings();
    patternFillSettings.setScale(100);
 
    // 9. Menambahkan isi Pola, di posisi tengah
    strokeEffect = psdImage.getLayers()[9].getBlendingOptions().addStroke(FillType.Pattern);
    strokeEffect.setSize(10);
    strokeEffect.setPosition(StrokePosition.Center);
    patternFillSettings = (IPatternFillSettings)strokeEffect.getFillSettings();
    patternFillSettings.setScale(75);
 
    psdImage.save(dstPngPath, new PngOptions());
}
finally
{
    psdImage.dispose();
}

PSDJAVA-249. Dukungan Sumber Daya lnk2 / lnk3 (Sumber Daya Lapisan Objek Pintar)

// Contoh ini menunjukkan bagaimana cara bekerja dengan sumber daya objek pintar (umumnya Lnk2Resource).
// Program memuat beberapa dokumen Photoshop dan mengekspor objek pintar mereka ke format file raster.
 
class LocalScopeExtension
{
    void assertAreEqual(Object expected, Object actual)
    {
        if (!actual.equals(expected))
        {
            throw new FormatException(String.format("Nilai aktual %s tidak sama dengan nilai yang diharapkan %s.", actual, expected));
        }
    }
 
    // Menyimpan data objek pintar ke file PSD
    void saveSmartObjectData(String filePath, byte[] data)
    {
        FileStreamContainer container = FileStreamContainer.createFileStream(filePath, false);
        try
        {
            container.write(data);
        }
        finally
        {
            container.dispose();
        }
    }
 
    // Memuat data baru untuk objek pintar dari file
    byte[] loadNewData(String filePath)
    {
        FileStreamContainer container = FileStreamContainer.openFileStream(filePath);
        try
        {
            return container.toBytes();
        }
        finally
        {
            container.dispose();
        }
    }
 
    // Mendapat dan menetapkan properti Lnk2 / Lnk3 Resource PSD dan sumber data LiFD-nya dalam gambar PSD
    void exampleOfLnk2ResourceSupport(
            String fileName,
            int dataSourceCount,
            int length,
            int newLength,
            Object[] dataSourceExpectedValues)
    {
        String srcPsdPath = fileName;
        String dstPsdPath = "out_" + fileName;
 
        PsdImage image = (PsdImage)Image.load(srcPsdPath);
        try
        {
            // Mencari Lnk2Resource
            Lnk2Resource lnk2Resource = null;
            for (LayerResource resource : image.getGlobalLayerResources())
            {
                if (resource instanceof Lnk2Resource)
                {
                    lnk2Resource = (Lnk2Resource)resource;
 
                    // Memverifikasi properti Lnk2Resource
                    assertAreEqual(lnk2Resource.getDataSourceCount(), dataSourceCount);
                    assertAreEqual(lnk2Resource.getLength(), length);
                    assertAreEqual(lnk2Resource.isEmpty(), false);
 
                    for (int i = 0; i < lnk2Resource.getDataSourceCount(); i++)
                    {
                        // Memverifikasi dan mengubah properti LiFdDataSource
                        LiFdDataSource lifdSource = lnk2Resource.get_Item(i);
                        Object[] expected = (Object[])dataSourceExpectedValues[i];
                        assertAreEqual(LinkDataSourceType.liFD, lifdSource.getType());
                        assertAreEqual(expected[0], lifdSource.getUniqueId().toString());
                        assertAreEqual(expected[1], lifdSource.getOriginalFileName());
                        assertAreEqual(expected[2], lifdSource.getFileType().trim());
                        assertAreEqual(expected[3], lifdSource.getFileCreator().trim());
                        assertAreEqual(expected[4], lifdSource.getData().length);
                        assertAreEqual(expected[5], lifdSource.getAssetModTime());
                        assertAreEqual(expected[6], lifdSource.getChildDocId());
                        assertAreEqual(expected[7], lifdSource.getVersion());
                        assertAreEqual(expected[8], lifdSource.hasFileOpenDescriptor());
                        assertAreEqual(expected[9], lifdSource.getLength());
 
                        if (lifdSource.hasFileOpenDescriptor())
                        {
                            assertAreEqual(-1, lifdSource.getCompId());
                            assertAreEqual(-1, lifdSource.getOriginalCompId());
                            lifdSource.setCompId(Integer.MAX_VALUE);
                        }
 
                        saveSmartObjectData(
                                fileName + "_" + lifdSource.getOriginalFileName(),
                                lifdSource.getData());
                        lifdSource.setData(loadNewData("new_" + lifdSource.getOriginalFileName()));
                        assertAreEqual(expected[10], lifdSource.getLength());
 
                        lifdSource.setChildDocId(UUID.randomUUID().toString());
                        lifdSource.setAssetModTime(Double.MAX_VALUE);
                        lifdSource.setFileType("test");
                        lifdSource.setFileCreator("me");
                    }
 
                    assertAreEqual(newLength, lnk2Resource.getLength());
                    break;
                }
            }
 
            // Memastikanbahwa Lnk2Resource ditemukan
            assertAreEqual(true, lnk2Resource != null);
 
            // Membuat salinan PSD yang dimuat
            if (image.getBitsPerChannel() < 32) 
            {
                image.save(dstPsdPath, new PsdOptions(image));
            }
        }
        finally
        {
            image.dispose();
        }
    }
}
LocalScopeExtension $ = new LocalScopeExtension();
 
Object[] Lnk2ResourceSupportCases = new Object[]
        {
                new Object[]
                        {
                                "00af34a0-a90b-674d-a821-73ee508c5479",
                                "rgb8_2x2.png",
                                "png",
                                "",
                                0x53,
                                0d,
                                "",
                                7,
                                true,
                                0x124L,
                                0x74cL
                        }
        };
 
Object[] LayeredLnk2ResourceSupportCases = new Object[]
        {
                new Object[]
                        {
                                "69ac1c0d-1b74-fd49-9c7e-34a7aa6299ef",
                                "huset.jpg",
                                "JPEG",
                                "",
                                0x9d46,
                                0d,
                                "xmp.did:0F94B342065B11E395B1FD506DED6B07",
                                7,
                                true,
                                0x9E60L,
                                0xc60cL
                        },
                new Object[]
                        {
                                "5a7d1965-0eae-b24e-a82f-98c7646424c2",
                                "panama-papers.jpg",
                                "JPEG",
                                "",
                                0xF56B,
                                0d,
                                "xmp.did:BDE940CBF51B11E59D759CDA690663E3",
                                7,
                                true,
                                0xF694L,
                                0x10dd4L
                        },
        };
 
Object[] LayeredLnk3ResourceSupportCases = new Object[]
        {
                new Object[]
                        {
                                "2fd7ba52-0221-de4c-bdc4-1210580c6caa",
                                "panama-papers.jpg",
                                "JPEG",
                                "",
                                0xF56B,
                                0d,
                                "xmp.did:BDE940CBF51B11E59D759CDA690663E3",
                                7,
                                true,
                                0xF694l,
                                0x10dd4L
                        },
                new Object[]
                        {
                                "372d52eb-5825-8743-81a7-b6f32d51323d",
                                "huset.jpg",
                                "JPEG",
                                "",
                                0x9d46,
                                0d,
                                "xmp.did:0F94B342065B11E395B1FD506DED6B07",
                                7,
                                true,
                                0x9E60L,
                                0xc60cL
                        },
        };
 
$.exampleOfLnk2ResourceSupport("rgb8_2x2_embedded_png.psd", 1, 0x12C, 0x0000079c, Lnk2ResourceSupportCases);
 
$.exampleOfLnk2ResourceSupport("Layered PSD file smart objects.psd", 2, 0x19504, 0x0001d3e0, LayeredLnk3ResourceSupportCases);
 
$.exampleOfLnk2ResourceSupport("LayeredSmartObjects16bit.psd", 2, 0x19504, 0x0001d3e0, LayeredLnk2ResourceSupportCases);

PSDJAVA-247. Perubahan Pesan Exception saat mencoba membuka format yang tidak didukung sebagai gambar

// Contoh ini menunjukkan bahwa pengecualian dengan pesan yang lebih deskriptif baru dilempar saat
// memuat gambar raster dengan cara yang tidak didukung (gambar raster hanya bisa dimuat sebagai layer).
 
String[] filesPaths = new String[]
        {
                "BmpExample.bmp",
                "GifExample.gif",
                "Jpeg2000Example.jpf",
                "JpegExample.jpg",
                "PngExample.png",
                "TiffExample.tif",
        };
 
String expectedExceptionMessage = "Tidak dapat membuka gambar. Format file gambar mungkin tidak didukung saat ini atau tidak dapat dibuka dengan cara tersebut. Jika Anda mencoba menambahkan Layer, silakan Buka File sebagai Stream dan gunakan metode AddLayer sebagai gantinya. Periksa dokumentasi https://docs.aspose.com/display/psdnet/Add+Layer+to+PSD";
 
for (String filePath : filesPaths)
{
    try
    {
        Image image = Image.load(filePath);
        image.dispose();
    }
    catch (Exception e)
    {
        // Memverifikasi apakah pengecualian yang dilempar memiliki pesan yang lebih deskriptif baru
        if (e.getInnerException() == null ||
                !e.getInnerException().getMessage().equals(expectedExceptionMessage))
        {
            throw e;
        }
    }
}

PSDJAVA-235. Jika kita menyimpan file PSD setelah membuat Grup Layer baru, kita akan mendapatkan peringatan Photoshop saat membuka file.

// Contoh ini menunjukkan bahwa tidak ada pengecualian saat menyimpan file PSD yang dihasilkan
// yang berisi grup layer internal.
 
String dstPsdPath = "psdnet_test_out.psd";
 
// Tentukan aturan tertentu untuk pembuatan gambar PSD
PsdOptions createOptions = new PsdOptions();
createOptions.setSource(new FileCreateSource(dstPsdPath, false));
createOptions.setPalette(new PsdColorPalette(new Color[] { Color.getRed(), Color.getGreen(), Color.getBlue() }));
PsdImage psdImage = (PsdImage)Image.create(createOptions, 500, 500);
try
{
    // Tambahkan hierarki grup layer dan layer ke dalam PSD
    LayerGroup group1 = psdImage.addLayerGroup("Group 1", 0, true);
 
    Layer layer1 = new Layer(psdImage);
    layer1.setName("Layer 1");
    group1.addLayer(layer1);
 
    LayerGroup group2 = group1.addLayerGroup("Group 2", 1);
 
    // Simpan PSD yang dihasilkan ke file fisik dan pastikan tidak ada pengecualian
    psdImage.save(dstPsdPath);
}
finally
{
    psdImage.dispose();
}