开源图片详细信息提取metadata-extractor

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wyyl1/article/details/45830073

网站:https://drewnoakes.com/code/exif/

GitHub:https://github.com/drewnoakes/metadata-extractor/

参考网站:http://www.programgo.com/article/10671752428/


使用版本:

<dependency>
	<groupId>com.drewnoakes</groupId>
	<artifactId>metadata-extractor</artifactId>
	<version>2.8.1</version>
</dependency>


import com.drew.imaging.ImageMetadataReader;
import com.drew.imaging.ImageProcessingException;
import com.drew.metadata.Directory;
import com.drew.metadata.Metadata;
import com.drew.metadata.Tag;

import java.io.File;
import java.io.IOException;

/**
 * @author wyyl1
 */
public class Test {

    /**
     * 图片数据元提取
     */
    public static void metadataExtractor(){
        File jpegFile = new File("37.jpg");
        try {
            Metadata metadata = ImageMetadataReader.readMetadata(jpegFile);
            for (Directory directory : metadata.getDirectories()) {
                for (Tag tag : directory.getTags()) {
                    System.out.println(tag);
                }
            }
        } catch (ImageProcessingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        metadataExtractor();
    }
}

输出:

[JPEG] Compression Type - Baseline
[JPEG] Data Precision - 8 bits
[JPEG] Image Height - 2336 pixels
[JPEG] Image Width - 4160 pixels
[JPEG] Number of Components - 3
[JPEG] Component 1 - Y component: Quantization table 0, Sampling factors 2 horiz/2 vert
[JPEG] Component 2 - Cb component: Quantization table 1, Sampling factors 1 horiz/1 vert
[JPEG] Component 3 - Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert
[Exif Thumbnail] Image Width - 512 pixels
[Exif Thumbnail] Image Height - 288 pixels
[Exif Thumbnail] Thumbnail Compression - JPEG (old-style)
[Exif Thumbnail] Orientation - Top, left side (Horizontal / normal)
[Exif Thumbnail] X Resolution - 72 dots per inch
[Exif Thumbnail] Y Resolution - 72 dots per inch
[Exif Thumbnail] Resolution Unit - Inch
[Exif Thumbnail] Thumbnail Offset - 1096 bytes
[Exif Thumbnail] Thumbnail Length - 29151 bytes
[Exif IFD0] Image Width - 4160 pixels
[Exif IFD0] Image Height - 2336 pixels
[Exif IFD0] Bits Per Sample - 8 8 8 bits/component/pixel
[Exif IFD0] Make - HUAWEI
[Exif IFD0] Model - H60-L02
[Exif IFD0] Orientation - Top, left side (Horizontal / normal)
[Exif IFD0] X Resolution - 72 dots per inch
[Exif IFD0] Y Resolution - 72 dots per inch
[Exif IFD0] Resolution Unit - Inch
[Exif IFD0] Software - H60-L02V100R001CHNC00B313
[Exif IFD0] Date/Time - 2015:04:17 11:07:20
[Exif IFD0] YCbCr Positioning - Center of pixel array
[Exif IFD0] Device Setting Description - 105 112 112 0
[Exif SubIFD] Document Name - 
[Exif SubIFD] Exposure Time - 1/1848 sec
[Exif SubIFD] F-Number - f/2.0
[Exif SubIFD] Exposure Program - Program normal
[Exif SubIFD] ISO Speed Ratings - 50
[Exif SubIFD] Exif Version - 2.10
[Exif SubIFD] Date/Time Original - 2015:04:17 11:07:20
[Exif SubIFD] Date/Time Digitized - 2015:04:17 11:07:20
[Exif SubIFD] Components Configuration - YCbCr
[Exif SubIFD] Shutter Speed Value - 1/1847 sec
[Exif SubIFD] Aperture Value - f/2.0
[Exif SubIFD] Brightness Value - 0
[Exif SubIFD] Exposure Bias Value - 0 EV
[Exif SubIFD] Metering Mode - Average
[Exif SubIFD] White Balance - Daylight
[Exif SubIFD] Flash - Flash did not fire
[Exif SubIFD] Focal Length - 3.79 mm
[Exif SubIFD] Makernote - [21 bytes]
[Exif SubIFD] User Comment - Hisilicon K3
[Exif SubIFD] Sub-Sec Time - 378554
[Exif SubIFD] Sub-Sec Time Original - 378554
[Exif SubIFD] Sub-Sec Time Digitized - 378554
[Exif SubIFD] FlashPix Version - 1.00
[Exif SubIFD] Color Space - sRGB
[Exif SubIFD] Exif Image Width - 4160 pixels
[Exif SubIFD] Exif Image Height - 2336 pixels
[Exif SubIFD] Sensing Method - One-chip color area sensor
[Exif SubIFD] File Source - Digital Still Camera (DSC)
[Exif SubIFD] Scene Type - Directly photographed image
[Exif SubIFD] Custom Rendered - Custom process
[Exif SubIFD] Exposure Mode - Auto exposure
[Exif SubIFD] White Balance Mode - Auto white balance
[Exif SubIFD] Digital Zoom Ratio - 1
[Exif SubIFD] Focal Length 35 - 28mm
[Exif SubIFD] Scene Capture Type - Standard
[Exif SubIFD] Gain Control - None
[Exif SubIFD] Contrast - None
[Exif SubIFD] Saturation - None
[Exif SubIFD] Sharpness - None
[Exif SubIFD] Subject Distance Range - Unknown
[File] File Name - 37.jpg
[File] File Size - 3156289 bytes
[File] File Modified Date - Tue Apr 21 23:00:32 CST 2015
[Interoperability] Interoperability Index - Recommended Exif Interoperability Rules (ExifR98)
[Interoperability] Interoperability Version - 1.00

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页