当前位置: 首页>>代码示例>>Java>>正文


Java JpegPhotoshopMetadata类代码示例

本文整理汇总了Java中org.apache.commons.imaging.formats.jpeg.JpegPhotoshopMetadata的典型用法代码示例。如果您正苦于以下问题:Java JpegPhotoshopMetadata类的具体用法?Java JpegPhotoshopMetadata怎么用?Java JpegPhotoshopMetadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JpegPhotoshopMetadata类属于org.apache.commons.imaging.formats.jpeg包,在下文中一共展示了JpegPhotoshopMetadata类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test

import org.apache.commons.imaging.formats.jpeg.JpegPhotoshopMetadata; //导入依赖的package包/类
@Test
public void test() throws Exception {
    final Map<String, Object> params = new HashMap<>();
    final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
    params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));

    final JpegImageMetadata metadata = (JpegImageMetadata) Imaging.getMetadata(imageFile, params);
    assertNotNull(metadata);
    assertNotNull(metadata.getPhotoshop());

    metadata.getPhotoshop().dump();

    final JpegPhotoshopMetadata psMetadata = metadata.getPhotoshop();
    final List<IptcRecord> oldRecords = psMetadata.photoshopApp13Data.getRecords();

    Debug.debug();
    for (final IptcRecord record : oldRecords) {
        if (record.iptcType != IptcTypes.CITY) {
            Debug.debug("Key: " + record.iptcType.getName() + " (0x"
                    + Integer.toHexString(record.iptcType.getType())
                    + "), value: " + record.getValue());
        }
    }
    Debug.debug();
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:26,代码来源:IptcDumpTest.java

示例2: testRemove

import org.apache.commons.imaging.formats.jpeg.JpegPhotoshopMetadata; //导入依赖的package包/类
@Test
public void testRemove() throws Exception {
    final ByteSource byteSource = new ByteSourceFile(imageFile);

    final Map<String, Object> params = new HashMap<>();
    final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
    params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));

    final JpegPhotoshopMetadata metadata = new JpegImageParser().getPhotoshopMetadata(
            byteSource, params);
    assertNotNull(metadata);

    final File noIptcFile = removeIptc(byteSource);
    
    final JpegPhotoshopMetadata outMetadata = new JpegImageParser().getPhotoshopMetadata(
            new ByteSourceFile(noIptcFile), params);
    
    // FIXME should either be null or empty
    assertTrue(outMetadata == null
            || outMetadata.getItems().size() == 0);
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:22,代码来源:IptcUpdateTest.java

示例3: testInsert

import org.apache.commons.imaging.formats.jpeg.JpegPhotoshopMetadata; //导入依赖的package包/类
@Test
public void testInsert() throws Exception {
    final ByteSource byteSource = new ByteSourceFile(imageFile);

    final Map<String, Object> params = new HashMap<>();
    final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
    params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));

    final JpegPhotoshopMetadata metadata = new JpegImageParser().getPhotoshopMetadata(
            byteSource, params);
    assertNotNull(metadata);

    final File noIptcFile = removeIptc(byteSource);

    final List<IptcBlock> newBlocks = new ArrayList<>();
    final List<IptcRecord> newRecords = new ArrayList<>();

    newRecords.add(new IptcRecord(IptcTypes.CITY, "Albany, NY"));
    newRecords.add(new IptcRecord(IptcTypes.CREDIT,
            "William Sorensen"));

    final PhotoshopApp13Data newData = new PhotoshopApp13Data(newRecords,
            newBlocks);

    final File updated = createTempFile(imageFile.getName()
            + ".iptc.insert.", ".jpg");
    try (FileOutputStream fos = new FileOutputStream(updated);
            OutputStream os = new BufferedOutputStream(fos)) {
        new JpegIptcRewriter().writeIPTC(new ByteSourceFile(
                noIptcFile), os, newData);
    }

    final ByteSource updateByteSource = new ByteSourceFile(updated);
    final JpegPhotoshopMetadata outMetadata = new JpegImageParser().getPhotoshopMetadata(
            updateByteSource, params);

    assertNotNull(outMetadata);
    assertTrue(outMetadata.getItems().size() == 2);
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:40,代码来源:IptcUpdateTest.java

示例4: testUpdate

import org.apache.commons.imaging.formats.jpeg.JpegPhotoshopMetadata; //导入依赖的package包/类
@Test
public void testUpdate() throws Exception {
    final ByteSource byteSource = new ByteSourceFile(imageFile);

    final Map<String, Object> params = new HashMap<>();
    final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
    params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));

    final JpegPhotoshopMetadata metadata = new JpegImageParser().getPhotoshopMetadata(byteSource, params);
    assertNotNull(metadata);

    final List<IptcBlock> newBlocks = metadata.photoshopApp13Data.getNonIptcBlocks();
    final List<IptcRecord> newRecords = new ArrayList<>();

    newRecords.add(new IptcRecord(IptcTypes.CITY, "Albany, NY"));
    newRecords.add(new IptcRecord(IptcTypes.CREDIT,
            "William Sorensen"));

    final PhotoshopApp13Data newData = new PhotoshopApp13Data(newRecords,
            newBlocks);

    final File updated = writeIptc(byteSource, newData);

    final ByteSource updateByteSource = new ByteSourceFile(updated);
    final JpegPhotoshopMetadata outMetadata = new JpegImageParser().getPhotoshopMetadata(
            updateByteSource, params);

    assertNotNull(outMetadata);
    assertTrue(outMetadata.getItems().size() == 2);
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:31,代码来源:IptcUpdateTest.java

示例5: testNoChangeUpdate

import org.apache.commons.imaging.formats.jpeg.JpegPhotoshopMetadata; //导入依赖的package包/类
@Test
public void testNoChangeUpdate() throws Exception {
    final ByteSource byteSource = new ByteSourceFile(imageFile);

    final Map<String, Object> params = new HashMap<>();
    final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
    params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));

    final JpegPhotoshopMetadata metadata = new JpegImageParser().getPhotoshopMetadata(byteSource, params);
    assertNotNull(metadata);

    final List<IptcBlock> newBlocks = metadata.photoshopApp13Data.getNonIptcBlocks();
    final List<IptcRecord> oldRecords = metadata.photoshopApp13Data.getRecords();
    final List<IptcRecord> newRecords = new ArrayList<>();
    for (final IptcRecord record : oldRecords) {
        if (record.iptcType != IptcTypes.CITY
                && record.iptcType != IptcTypes.CREDIT) {
            newRecords.add(record);
        }
    }

    newRecords.add(new IptcRecord(IptcTypes.CITY, "Albany, NY"));
    newRecords.add(new IptcRecord(IptcTypes.CREDIT, "William Sorensen"));

    final PhotoshopApp13Data newData = new PhotoshopApp13Data(newRecords, newBlocks);

    final File updated = writeIptc(byteSource, newData);

    final ByteSource updateByteSource = new ByteSourceFile(updated);
    final JpegPhotoshopMetadata outMetadata = new JpegImageParser().getPhotoshopMetadata(updateByteSource, params);

    assertNotNull(outMetadata);
    assertTrue(outMetadata.getItems().size() == newRecords.size());
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:35,代码来源:IptcUpdateTest.java

示例6: testAddIptcData

import org.apache.commons.imaging.formats.jpeg.JpegPhotoshopMetadata; //导入依赖的package包/类
@Test
public void testAddIptcData() throws Exception {
    final ByteSource byteSource = new ByteSourceFile(imageFile);

    final Map<String, Object> params = new HashMap<>();
    final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
    params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));

    final JpegPhotoshopMetadata metadata = new JpegImageParser().getPhotoshopMetadata(byteSource, params);
    if (metadata == null) {
        // FIXME select only files with meta for this test
        return;
    }

    final List<IptcBlock> newBlocks = new ArrayList<>();
    newBlocks.addAll(metadata.photoshopApp13Data.getNonIptcBlocks());
    final List<IptcRecord> oldRecords = metadata.photoshopApp13Data.getRecords();

    final List<IptcRecord> newRecords = new ArrayList<>();
    for (final IptcRecord record : oldRecords) {
        if (record.iptcType != IptcTypes.CITY
                && record.iptcType != IptcTypes.CREDIT) {
            newRecords.add(record);
        }
    }

    newRecords.add(new IptcRecord(IptcTypes.CITY, "Albany, NY"));
    newRecords.add(new IptcRecord(IptcTypes.CREDIT, "William Sorensen"));

    final PhotoshopApp13Data newData = new PhotoshopApp13Data(newRecords, newBlocks);

    final File updated = createTempFile(imageFile.getName() + ".iptc.add.", ".jpg");
    try (FileOutputStream fos = new FileOutputStream(updated);
            OutputStream os = new BufferedOutputStream(fos)) {
        new JpegIptcRewriter().writeIPTC(byteSource, os, newData);
    }

    final ByteSource updateByteSource = new ByteSourceFile(updated);
    final JpegPhotoshopMetadata outMetadata = new JpegImageParser().getPhotoshopMetadata(
            updateByteSource, params);

    assertNotNull(outMetadata);
    assertTrue(outMetadata.getItems().size() == newRecords.size());
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:45,代码来源:IptcAddTest.java


注:本文中的org.apache.commons.imaging.formats.jpeg.JpegPhotoshopMetadata类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。