【问题标题】:Get ICC Profile information from Adobe Experience Manager asset从 Adob​​e Experience Manager 资产中获取 ICC 配置文件信息
【发布时间】:2021-06-08 09:28:46
【问题描述】:

我正在尝试从资产中获取 ICC PRofile 信息,但没有成功。有没有办法在工作流步骤中的资产处理期间获取这些字段?

我有一个类似的代码来获取在继承自 WorkflowProcess 的类中实现的资产对象(它只是为了描述我的问题):

 ResourceResolver resolver = workflowSession.adaptTo(ResourceResolver.class);

String path = workItem.getWorkflowData().getPayload().toString();
if (StringUtils.contains(path, JcrConstants.JCR_CONTENT)) {
    path = StringUtils.substringBefore(path, JcrConstants.JCR_CONTENT);
}

Resource resource = resolver.getResource(path);
Asset asset = resource == null ? null : resource.adaptTo(Asset.class);

if (asset == null) {
    log.info("Asset is null, skipping metadata extraction");
}

assert asset != null;
String layerName = asset.getMetadata("photoshop:LayerName") != null ? asset.getMetadata("photoshop:LayerName").toString() : "";

Map<String, Object> meta = asset.getMetadata();

在最后一行,我看不到元数据 ICC 字段。

有什么建议吗?

【问题讨论】:

    标签: java osgi aem


    【解决方案1】:

    好的,终于解决了

    我用过这个库

    org.apache.commons.imaging 
    

    然后就很简单了

    Asset asset = resource == null ? null : resource.adaptTo(Asset.class);
    Iterator<? extends Rendition> rendition = asset.listRenditions();
    if (rendition.hasNext()) {
        Rendition ren = rendition.next();
    
        try {
            byte[] assetByteArray = new byte[ren.getStream().available()];
            ren.getStream().read(assetByteArray);
    
            Imaging.getImageInfo(assetByteArray).getColorType();
    
            ICC_Profile iccProfile = Imaging.getICCProfile(assetByteArray);
            if (iccProfile != null) {
                int cs = iccProfile.getColorSpaceType();
    
                String colorSpaceName = getColorSpaceName(cs);
    
                Resource assetResource = resolver.getResource(path);
                Resource metadatResource = assetResource.getChild(DamConstants.METADATA_PATH);
    
                ModifiableValueMap mvmForAsset = metadatResource.adaptTo(ModifiableValueMap.class);
                mvmForAsset.put(DamConstants.ASSET_COLORSPACE, colorSpaceName);
    
                try {
                    resolver.commit();
                } catch (PersistenceException e) {
                    log.error("Error occurred during saving metadata value {}", e.getMessage());
                } finally {
                    resolver.close();
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-16
      • 1970-01-01
      • 1970-01-01
      • 2020-05-02
      • 1970-01-01
      相关资源
      最近更新 更多