本文整理汇总了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();
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}