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


Java Imaging.getMetadata方法代码示例

本文整理汇总了Java中org.apache.commons.imaging.Imaging.getMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java Imaging.getMetadata方法的具体用法?Java Imaging.getMetadata怎么用?Java Imaging.getMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.imaging.Imaging的用法示例。


在下文中一共展示了Imaging.getMetadata方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setExifGPSTag

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
/**
 * This method sets the EXIF the of the JPEG file and outputs it to given directory.
 * @param jpegImageFile
 * 		Input jpeg file.
 * @param dst
 * 		output jpeg file.
 * @param longitude
 * 		Longitude to be tagged.
 * @param latitude
 * 	 	Latitude to be tagged.
 * @throws IOException
 * @throws ImageReadException
 * @throws ImageWriteException
 */
public static void setExifGPSTag(final File jpegImageFile, final File dst, final double longitude, final double latitude) throws IOException,
ImageReadException, ImageWriteException {
	OutputStream os = null;
	boolean canThrow = false;
	try {

		final IImageMetadata metadata = Imaging.getMetadata(jpegImageFile);
		final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
		TiffOutputSet outputSet = setTiffOutputSet(jpegMetadata, longitude, latitude);
		os = new FileOutputStream(dst);
		os = new BufferedOutputStream(os);
		new ExifRewriter().updateExifMetadataLossless(jpegImageFile, os, outputSet);
		canThrow = true;
	} finally {
		IoUtils.closeQuietly(canThrow, os);
	}
}
 
开发者ID:codailama,项目名称:GeoTagPhotos,代码行数:32,代码来源:EXIFUtils.java

示例2: getExif

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private static TiffImageMetadata getExif(final File file) {
    TiffImageMetadata exif = null;
    try {
        final IImageMetadata metadata = Imaging.getMetadata(file);
        if (metadata != null) {
            final JpegImageMetadata jpegMetadata
                    = (JpegImageMetadata) metadata;
            exif = jpegMetadata.getExif();
        } else {
            log(Level.WARNING, String.format(
                    "No metadata found for file %s", file));
        }

    }
    catch (final ImageReadException | IOException ex) {
        Logger.getLogger(PhotoLoader.class.getName()).
                log(Level.SEVERE, null, ex);
    }
    return exif;
}
 
开发者ID:consulion,项目名称:jeotag,代码行数:21,代码来源:PhotoLoader.java

示例3: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的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

示例4: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的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 ImageMetadata metadata = Imaging.getMetadata(imageFile, params);
    // TODO only run this tests with images that have metadata...
    //assertNotNull(metadata);
    Debug.debug("metadata", metadata);
    
    Debug.debug("ICC profile", Imaging.getICCProfile(imageFile, params));

    final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
    assertNotNull(imageInfo);
    
    try {
        final BufferedImage image = Imaging.getBufferedImage(imageFile, params);
        assertNotNull(image);
    } catch (final ImageReadException imageReadException) {
        assertEquals("Only sequential, baseline JPEGs are supported at the moment",
                imageReadException.getMessage());
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:25,代码来源:JpegReadTest.java

示例5: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    Debug.debug("start");

    final List<File> images = getXpmImages();
    for (final File imageFile : images) {

        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        Assert.assertFalse(metadata instanceof File); // Dummy check to avoid unused warning (it may be null)

        final Map<String, Object> params = new HashMap<>();
        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
        assertNotNull(imageInfo);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:21,代码来源:XpmReadTest.java

示例6: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    Debug.debug("start");

    final List<File> images = getPsdImages();
    for (final File imageFile : images) {

        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        Assert.assertFalse(metadata instanceof File); // Dummy check to avoid unused warning (it may be null)

        final Map<String, Object> params = new HashMap<>();
        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
        assertNotNull(imageInfo);

        Imaging.getICCProfile(imageFile, params);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:23,代码来源:PsdReadTest.java

示例7: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    Debug.debug("start");

    final List<File> images = getPcxImages();
    for (int i = 0; i < images.size(); i++) {

        final File imageFile = images.get(i);
        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        Assert.assertFalse(metadata instanceof File); // Dummy check to avoid unused warning (it may be null)

        final Map<String, Object> params = new HashMap<>();
        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
        assertNotNull(imageInfo);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:22,代码来源:PcxReadTest.java

示例8: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    Debug.debug("start");

    final List<File> images = getPamImages();
    for (int i = 0; i < images.size(); i++) {

        final File imageFile = images.get(i);
        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        Assert.assertFalse(metadata instanceof File); // Dummy check to avoid unused warning (it may be null)

        final Map<String, Object> params = new HashMap<>();
        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
        assertNotNull(imageInfo);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:22,代码来源:PamReadTest.java

示例9: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    final List<File> images = getTiffImages();
    for (final File imageFile : images) {

        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        assertNotNull(metadata);

        Debug.debug("ICC profile", Imaging.getICCProfile(imageFile));

        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile);
        assertNotNull(imageInfo);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:20,代码来源:TiffReadTest.java

示例10: read

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Override public PhotoMetadata read(InputStream is) throws DAOException {
    if (is == null)
        throw new IllegalArgumentException();
    LOGGER.debug("reading metadata");

    ImageMetadata imageData;
    try {
        imageData = Imaging.getMetadata(is, null);
    } catch (ImageReadException | IOException ex) {
        LOGGER.warn("failed reading metadata");
        throw new FormatException(ex);
    }

    PhotoMetadata result = new PhotoMetadata();
    if (imageData == null) {
        LOGGER.debug("could not find image metadata");
        return result;
    }

    if (!(imageData instanceof JpegImageMetadata)) {
        LOGGER.debug("metadata is of unknown type");
        return result;
    }

    JpegImageMetadata jpegData = (JpegImageMetadata) imageData;
    readDate(jpegData, result);
    readGps(jpegData, result);
    readMetaData(jpegData, result);
    return result;
}
 
开发者ID:travelimg,项目名称:travelimg,代码行数:31,代码来源:JpegSerializer.java

示例11: copyExifOrientation

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
/**
 * This method will copy the Exif "orientation" information to the resulting image, if the
 * original image contains this data too.
 *
 * @param sourceImage
 *            The source image.
 * @param result
 *            The original result.
 * @return The new result containing the Exif orientation.
 */
public static byte[] copyExifOrientation(byte[] sourceImage, byte[] result) {
    try {
        ImageMetadata imageMetadata = Imaging.getMetadata(sourceImage);
        if (imageMetadata == null) {
            return result;
        }
        List<? extends ImageMetadata.ImageMetadataItem> metadataItems = imageMetadata
                .getItems();
        for (ImageMetadata.ImageMetadataItem metadataItem : metadataItems) {
            if (metadataItem instanceof TiffImageMetadata.TiffMetadataItem) {
                TiffField tiffField = ((TiffImageMetadata.TiffMetadataItem) metadataItem)
                        .getTiffField();
                if (!tiffField.getTagInfo().equals(TiffTagConstants.TIFF_TAG_ORIENTATION)) {
                    continue;
                }
                Object orientationValue = tiffField.getValue();
                if (orientationValue == null) {
                    break;
                }
                TiffOutputSet outputSet = new TiffOutputSet();
                TiffOutputDirectory outputDirectory = outputSet.getOrCreateRootDirectory();
                outputDirectory.add(TiffTagConstants.TIFF_TAG_ORIENTATION,
                        ((Number) orientationValue).shortValue());
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

                new ExifRewriter().updateExifMetadataLossy(result, outputStream, outputSet);
                return outputStream.toByteArray();
            }
        }
    } catch (IOException | ImageWriteException | ImageReadException e) {
        LOGGER.warn("Error reading image: {}", e.getMessage());
    }
    return result;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:45,代码来源:ImageHelper.java

示例12: testSingleImage

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void testSingleImage() throws Exception {
    final File imageFile = getTestImageByName("img_F028c_small.jpg");

    final Map<String, Object> params = new HashMap<>();
    final ImageMetadata metadata = Imaging.getMetadata(imageFile, params);
    assertNotNull(metadata);
    final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
    final BufferedImage image = jpegMetadata.getEXIFThumbnail();
    assertNotNull(image);
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:12,代码来源:JpegWithJpegThumbnailTest.java

示例13: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    if (imageFile.getParentFile().getName().toLowerCase().equals("@broken")) {
        return;
    }

    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);
    if (null == metadata) {
        return;
    }

    final TiffImageMetadata exifMetadata = metadata.getExif();
    if (null == exifMetadata) {
        return;
    }

    final TiffImageMetadata.GPSInfo gpsInfo = exifMetadata.getGPS();
    if (null == gpsInfo) {
        return;
    }

    // TODO we should assert something here.
    Debug.debug("imageFile " + imageFile);
    Debug.debug("gpsInfo " + gpsInfo);
    Debug.debug("gpsInfo longitude as degrees east " + gpsInfo.getLongitudeAsDegreesEast());
    Debug.debug("gpsInfo latitude as degrees north " + gpsInfo.getLatitudeAsDegreesNorth());
    Debug.debug();

}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:34,代码来源:GpsTest.java

示例14: checkImage

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private void checkImage(final File imageFile) throws IOException,
        ImageReadException, ImageWriteException {
    // Debug.debug("imageFile", imageFile.getAbsoluteFile());

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

    // note that metadata might be null if no metadata is found.
    final ImageMetadata metadata = Imaging.getMetadata(imageFile, params);
    if (null == metadata) {
        return;
    }
    final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;

    // note that exif might be null if no Exif metadata is found.
    final TiffImageMetadata exif = jpegMetadata.getExif();
    if (null == exif) {
        return;
    }

    final List<TiffField> fields = exif.getAllFields();
    for (final TiffField field : fields) {
        checkField(imageFile, field);
    }

}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:28,代码来源:SpecificExifTagTest.java

示例15: testMetadata

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void testMetadata() 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);
    // TODO assert more
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:11,代码来源:ExifDumpTest.java


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