Packages

 

com.aspose.psd.fileformats.psd.layers.smartobjects

Class SmartObjectLayer

  • All Implemented Interfaces:
    IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader


    public class SmartObjectLayer
    extends Layer

    Defines the SmartObjectLayer class that contains embedded in the PSD file or linked smart object in the external file. With Smart Objects, you can: Perform nondestructive transforms. You 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. Work with vector data, such as vector artwork from Illustrator, that otherwise would be rasterized. Perform nondestructive filtering. You can edit filters applied to Smart Objects at any time. Edit one Smart Object and automatically update all its linked instances. Apply a layer mask that�s either linked or unlinked to the Smart Object layer. Try various designs with low-resolution placeholder images that you later replace with final versions. In Adobe� Photoshop�, you can embed the contents of an image into a PSD document. More information is here: A layer with an embedded smart object contains placed (PlLd) and SoLd resources with smart object properties. The PlLd resource can be alone for PSD versions older then 10. These resources contain UniqueId of the LiFdDataSource in the global Lnk2Resource with the embedded filename and other parameters, including the embedded file contents in the original format as a byte array.

    See Also:
    Layer, SmartObjectProvider, LinkDataSource
    • Method Detail

      • getContentsBounds

        public final Rectangle getContentsBounds()

        Gets or sets the smart object content's bounds.

        Value: The smart object bounds.
      • setContentsBounds

        public final void setContentsBounds(Rectangle value)

        Gets or sets the smart object content's bounds.

        Value: The smart object bounds.
      • getContentsSource

        public final LinkDataSource getContentsSource()

        Gets or sets the smart object content's source.

        Value: The smart object data source.
      • setContentsSource

        public final void setContentsSource(LinkDataSource value)

        Gets or sets the smart object content's source.

        Value: The smart object data source.
      • getContents

        public final byte[] getContents()

        Gets or sets the smart object layer contents. The embedded smart object contents is the embedded raw image file: LiFdDataSource.Data and its properties. The linked smart object contents is the raw content of the linked image file if it is available and its properties: LiFeDataSource. We do not support loading from the Adobe� Photoshop� �� Graphics Library when LinkDataSource.IsLibraryLink(LinkDataSource.isLibraryLink()/LinkDataSource.setLibraryLink(boolean)) is true. For regular link files, at first, we use LiFeDataSource.RelativePath(LiFeDataSource.getRelativePath()/LiFeDataSource.setRelativePath(String)) to look for the file relatively to the source image path DataStreamSupporter.SourceImagePath, if it is not available we look at LiFeDataSource.FullPath(LiFeDataSource.getFullPath()/LiFeDataSource.setFullPath(String)), if not then we look for the link file in the same directory where our image is: DataStreamSupporter.SourceImagePath.

        Throws:
        com.aspose.ms.System.NotSupportedException - Cannot get contents from Adobe� Photoshop� �� library. Value: The byte[] smart object layer contents.
      • setContents

        public final void setContents(byte[] value)

        Gets or sets the smart object layer contents. The embedded smart object contents is the embedded raw image file: LiFdDataSource.Data and its properties. The linked smart object contents is the raw content of the linked image file if it is available and its properties: LiFeDataSource. We do not support loading from the Adobe� Photoshop� �� Graphics Library when LinkDataSource.IsLibraryLink(LinkDataSource.isLibraryLink()/LinkDataSource.setLibraryLink(boolean)) is true. For regular link files, at first, we use LiFeDataSource.RelativePath(LiFeDataSource.getRelativePath()/LiFeDataSource.setRelativePath(String)) to look for the file relatively to the source image path DataStreamSupporter.SourceImagePath, if it is not available we look at LiFeDataSource.FullPath(LiFeDataSource.getFullPath()/LiFeDataSource.setFullPath(String)), if not then we look for the link file in the same directory where our image is: DataStreamSupporter.SourceImagePath.

        Throws:
        com.aspose.ms.System.NotSupportedException - Cannot get contents from Adobe� Photoshop� �� library. Value: The byte[] smart object layer contents.
      • getSmartObjectProvider

        public final SmartObjectProvider getSmartObjectProvider()

        Gets the smart object provider.

        Value: The smart object provider.
      • exportContents

        public final void exportContents(String filePath)

        Exports the embedded or linked contents to a file.

        Parameters:
        filePath - The export file path.
      • loadContents

        public final Image loadContents(LoadOptions options)

        Gets the embedded or linked image contents of the smart object layer.

        Parameters:
        options - The options.
        Returns:
        The loaded Image smart object instance.
      • replaceContents

        public final void replaceContents(Image image)

        Replaces the smart object contents embedded in the smart object layer.

        Parameters:
        image - The image.
      • replaceContents

        public final void replaceContents(Image image,
                                          ResolutionSetting resolution)

        Replaces the smart object contents embedded in the smart object layer.

        Parameters:
        image - The image.
        resolution - The resolution settings. If null the image resolution will be used.
        Throws:
        PsdImageException - Can only replace embedded smart object.
      • replaceContents

        public final void replaceContents(String linkedPath,
                                          ResolutionSetting resolution)

        Replaces the contents with a file. There is no need to call UpdateModifiedContent method afterwards.

        Parameters:
        linkedPath - The linked path.
        resolution - The resolution settings. If null the image resolution will be used.
      • replaceContents

        public final void replaceContents(String linkedPath)

        Replaces the contents with a file. There is no need to call UpdateModifiedContent method afterwards.

        Parameters:
        linkedPath - The linked path.
      • embedLinked

        public final void embedLinked()

        Embeds the linked smart object in this layer.

      • convertToLinked

        public final void convertToLinked(String linkedPath)

        Converts this embedded smart object to a linked smart object.

        Parameters:
        linkedPath - The linked path.
      • relinkToFile

        public final void relinkToFile(String linkedPath)

        Re-links the linked smart object to a new file. There is no need to call UpdateModifiedContent method afterwards.

        Parameters:
        linkedPath - The linked path.
      • updateModifiedContent

        public final void updateModifiedContent()

        Updates the smart object layer image cache with the modified content.

      • newSmartObjectViaCopy

        public final SmartObjectLayer newSmartObjectViaCopy()

        Creates a new smart object layer by coping this one. Reproduces `Layer -> Smart Objects -> New Smart Object via Copy` functionality of Adobe� Photoshop�. Notice that it is enabled only for embedded smart objects because the embedded image is also copied. If you want to share the embedded image use SmartObjectLayer.duplicateLayer() method.

        Returns:
        The cloned SmartObjectLayer instance.