java 读取JPEG图像的Exif信息

Wesley13
• 阅读 693

注意:所有类型图像文件中,只有JPEG具有Exif信息

public class JpegDecodeTest {

    
    public static byte[] getJPEGBytes(String filename)
    {
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(filename);
            int available = fis.available();
            ByteArrayOutputStream baos = new ByteArrayOutputStream(available);
            int len = -1;
            byte[] buf = new byte[1028];
            while ((len=fis.read(buf, 0, buf.length))!=-1)
            {
                baos.write(buf, 0, len);
            }
            return baos.toByteArray();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally{
            if(fis!=null)
            {
                try {
                    fis.close();
                } catch (IOException e) {
                }
            }
        }
        return null;
    }
    public static void main(String[] args) throws JSONException, IOException {
            
        byte[] buf = getJPEGBytes("ttt.png");
        for (int i = 0; i < buf.length; i++)
        {
                int b = buf[i]&0xff;
                if(i>0 &&buf[i-1]==-1)
                {
                        String s = null;
                        switch (b) {
                        case 0xD8:
                            s = "SOI";
                            break;
                        case 0xDB:
                            s = "DQT";
                            showJPEGDHQ(buf,i);
                            break;
                        case 0xE0:
                        {
                            s = "APP0";
                            showJPEGApp0(buf,i);
                        }
                            break;
                        case 0xC0:
                            s = "SOF0";
                            showJPEGSOF0(buf,i);
                            break;
                        case 0xC4:
                            s = "DHT";
                            break;
                        case 0xDD:
                            s = "DRI";
                            break;
                        case 0xDA:
                            s = "SOS";
                            break;
                        case 0xD9:
                            s = "EOI";
                            break;
                            
                        default:
                        {
                            int H = (int)(b&0xff);
                            if(H>=0xE1 && 0xEF>=H)
                            {
                                s = "APPE"+(H-225+1);
                                showJPEGAppH(buf, i);
                            }
                        }
                            break;
                        }
                        if(s!=null)
                        {
                            System.out.println(" FIND-Flag: "+s);
                        }
                    }
                }
        
    }
    private static void showJPEGDHQ(byte[] buf, int i)
    {

        if(buf==null || buf.length<=i)
        {
            return;
        }
        int startIndex = i+1;
        int len = getByteToInteger(buf, startIndex, 2, true);
        System.out.println("DHQ长度:"+len);
    }
    private static void showJPEGSOF0(byte[] buf, int i)
    {
        if(buf==null || buf.length<=i)
        {
            return;
        }
        int startIndex = i+1;
        int len = getByteToInteger(buf, startIndex, 2, true);
        System.out.println("App0长度:"+len);
        byte[] sof0Buf = new byte[len];
        System.arraycopy(buf, startIndex, sof0Buf, 0, len);
        startIndex = 0;
        startIndex = startIndex + 2;
        
        int degree = sof0Buf[startIndex]&0XFF; //精度
        int width = getByteToInteger(sof0Buf, startIndex+1, 2, true);
        int height = getByteToInteger(sof0Buf, startIndex+3, 2, true);
        int xyDelta = sof0Buf[startIndex+5]&0XFF; //颜色分量
        startIndex = startIndex + 6;
        int restLen = len - startIndex;
        
        
    }
    private static void showJPEGApp0(byte[] buf, int i)
    {
        
        if(buf==null || buf.length<=i)
        {
            return;
        }
        int startIndex = i+1;
        int len = getByteToInteger(buf, startIndex, 2, true);
        System.out.println("App0长度:"+len);
        
        startIndex = startIndex +2;
        String flag = getStrings(buf, startIndex, 5).trim();
        System.out.println("flag:"+flag);
        
        if("JFIF".equalsIgnoreCase(flag))
        {
            startIndex = startIndex+5;
            String version = (buf[startIndex]&0xFF) +"."+(buf[startIndex+1]&0xFF);
            System.out.println("version="+version);
            
            startIndex = startIndex +2;
            int densityUnit = buf[startIndex]&0xFF; //像素单位
            
            int XDensity = getByteToInteger(buf, startIndex+1, 2, true);
            int YDensity = getByteToInteger(buf, startIndex+3, 2, true);
            
            startIndex = startIndex +5;
            String XYPixesBlockNumbers = (buf[startIndex]&0xFF) +"/"+(buf[startIndex+1]&0xFF);
            startIndex = startIndex +2;
            
            System.out.println("densityUnit="+densityUnit+", XDensity="+XDensity+", YDensity="+YDensity+", XYPixesBlockNumbers="+XYPixesBlockNumbers);
            int rest = len - (startIndex-i-1);
            if("0/0".equals(XYPixesBlockNumbers) || rest==0)
            {
                System.out.println("没有缩略图位图!");
            }else{
                byte[] bmpBytes = new byte[rest];
                System.arraycopy(buf, startIndex, bmpBytes, 0, rest);
                System.out.println("RGB位图大小:"+bmpBytes.length);
            }
        
        }
        
    }
    private static void showJPEGAppH(byte[] buf, int i) throws IOException
    {
        
        if(buf==null || buf.length<=i)
        {
            return;
        }
        int len = getByteToInteger(buf, i+1, 2, true);
        System.out.println("本段长度:"+len);
        
        byte[] appbuf = new byte[len];
        System.arraycopy(buf, i+1, appbuf, 0, len);
        
        int k = 2;
        
        String strIfExif = getStrings(appbuf, k, 4);
        if("Exif".equalsIgnoreCase(strIfExif))
        {
            int iTIFFOffset = k + 4;
            //大小端保存问题,占4个字节
            int bytesToInt = getByteToInteger(appbuf, iTIFFOffset, 4, true);
            boolean isBigEndian = false;
            if(bytesToInt==0x4949)
            { //小端模式
                isBigEndian = false; 
            }else if(bytesToInt==0x4D4D){ //大端模式
                isBigEndian = true;
            }else{
                System.out.println("Not valid TIFF data! (no 0x4949 or 0x4D4D)");
                return;
            }
            
            if(isBigEndian)
            {
                System.out.println("大端模式");
                
                iTIFFOffset = iTIFFOffset + 4;
                int checkNumber = getByteToInteger(appbuf, iTIFFOffset, 2, isBigEndian);
                System.out.println("checkNumber="+checkNumber);
                boolean isValidExif = true;
                if(checkNumber!=0x002A){
                    isValidExif = false;
                    System.out.println("Not valid TIFF data! (no 0x002A)");
                    return;
                }
                iTIFFOffset = iTIFFOffset + 2;
                checkNumber = getByteToInteger(appbuf, iTIFFOffset, 4,isBigEndian);
                System.out.println("checkNumber="+checkNumber);
                
                if (checkNumber!= 0x0008) 
                {
                    isValidExif = false;
                    System.out.println("Not valid TIFF data! (First offset not 8)");
                    return;
                }
                
                Map<String, Object> map = readTagInfo(Exif.TiffTags.class, appbuf, iTIFFOffset,iTIFFOffset+4, isBigEndian);
                if(map.containsKey("ExifIFDPointer"))
                {    
                     int ExifIFDPointerOffset  = (int) map.get("ExifIFDPointer")+iTIFFOffset-4;
                     System.out.println(ExifIFDPointerOffset);
                     Map<String, Object> readTagInfo = readTagInfo(Exif.Tags.class, appbuf, iTIFFOffset,ExifIFDPointerOffset, isBigEndian);
                     map.putAll(readTagInfo);
                }
                
                if (map.containsKey("GPSInfoIFDPointer")) {
                     int GPSInfoIFDPointer  = (int) map.get("GPSInfoIFDPointer")+iTIFFOffset-4;
                     System.out.println(GPSInfoIFDPointer);
                     Map<String, Object> readTagInfo = readTagInfo(Exif.GPSTags.class, appbuf, iTIFFOffset,GPSInfoIFDPointer, isBigEndian);
                     map.putAll(readTagInfo);
                }
                
                System.out.println(map);
            }else{
                System.out.println("小端模式");
            }
            
        }else{
            strIfExif = new String(buf, i,len);
            System.out.println(strIfExif);
        }
    }
    private static Map<String, Object> readTagInfo(Class clazz, byte[] appbuf, int iTIFFOffset,int startDir, boolean isBigEndian) {
        int iEntries = getByteToInteger(appbuf, startDir, 2, isBigEndian);
        Map<String, Object> map = new HashMap<String, Object>();
        for (int t=0;t<iEntries;t++) 
        {
            int iEntryOffset = (startDir+2) + t*12; //每个报文段长度是12
            
            int iType             = getByteToInteger(appbuf, iEntryOffset+2, 2, isBigEndian);
            int iNumValues         = getByteToInteger(appbuf, iEntryOffset+4, 4, isBigEndian);
            //计算数据的偏移位置
            int iValueOffset     = getByteToInteger(appbuf, iEntryOffset+8, 4, isBigEndian)+iTIFFOffset-4;
            
            String strTag = readTag(clazz,getByteToInteger(appbuf, iEntryOffset, 2, isBigEndian),isBigEndian);
            Object values = readTagValue(appbuf,iType,iValueOffset,iNumValues,iEntryOffset);
            System.err.println(strTag+"["+iType+","+iNumValues+","+iValueOffset+"] ="+values);
            map.put(strTag, values);
        }
        return map;
    }
    
    private static Object readTagValue(byte[] appbuf, int iType, int iValueOffset,int iNumValues,int iEntryOffset) {
        
        Object value = null;
        switch (iType) {
        case 1:
        case 7:
        {
            if (iNumValues == 1) {
                value =  appbuf[iEntryOffset + 8];
            } else {
                int iValOffset = iNumValues > 4 ? iValueOffset : (iEntryOffset + 8);
                String[] aVals = new String[iNumValues];
                for (int n=0;n<iNumValues;n++) {
                    aVals[n] = appbuf[iValOffset + n]+"";
                }
                value = Arrays.asList(aVals);
            }
        }
            break;
        case 2:
            int iStringOffset = iNumValues>4?iValueOffset : (iEntryOffset + 8);
            value = getStrings(appbuf,iStringOffset,iNumValues-1);
            break;
        case 3:
        {
            if (iNumValues == 1) {
                value = getByteToInteger(appbuf, iEntryOffset+8, 4, true);
            } else if(iNumValues >= 2){
                int iValOffset = iNumValues > 2 ? iValueOffset : (iEntryOffset + 8);
                String[] aVals = new String[iNumValues];
                for (int n=0;n<iNumValues;n++) {
                    aVals[n] =getByteToInteger(appbuf, iValueOffset + 2*n, 4, true)+"";
                }
                value = Arrays.asList(aVals);
            }
        }
            break;
        case 4:
        {
            if (iNumValues == 1) {
                value = getByteToInteger(appbuf, iEntryOffset+8, 4, true);
            } else {
                String[] aVals = new String[iNumValues];
                for (int n=0;n<iNumValues;n++) {
                    aVals[n] =getByteToInteger(appbuf, iValueOffset + 4*n, 4, true)+"";
                }
                value = Arrays.asList(aVals);
            }
        }
            break;
        case 5:
        {
            if (iNumValues == 1) {
                value = ""+getByteToInteger(appbuf, iValueOffset, 4, true)+"/"+getByteToInteger(appbuf, iValueOffset+4, 4, true);
            } else {
                String[] values = new String[iNumValues];
                for (int n=0;n<iNumValues;n++) {
                    values[n] = getByteToInteger(appbuf, iValueOffset+8*n, 4, true) +"/"+ getByteToInteger(appbuf, iValueOffset+4+8*n, 4, true);
                }
                value = Arrays.asList(values);
            }
        }
            break;
        case 9:
            
            break;
        case 10:
        {
            if (iNumValues == 1) {
                value = getByteToInteger(appbuf, iValueOffset, 4, true) +"/"+getByteToInteger(appbuf, iValueOffset+4, 4, true);
            } else {
                String[] aVals = new String[iNumValues];
                for (int n=0;n<iNumValues;n++) {
                    aVals[n] = ""+getByteToInteger(appbuf,iValueOffset + 8*n,4, true) +"/"+ getByteToInteger(appbuf,iValueOffset+4 + 8*n,4, true);
                }
                value = Arrays.asList(aVals);
            }
        }
            break;
        default:
            System.err.println("Invalid range ["+iType+","+iNumValues+","+iValueOffset+"]");
            break;
        }
        
        return value;
    }
    private static String readTag(Class clazz,int id,boolean isBigEndian) 
    {
        Field[] fields = clazz.getDeclaredFields();
        try {
            for (Field field : fields) {
                field.setAccessible(true);
                if(!Modifier.isStatic(field.getModifiers()))
                {
                    continue;
                }
                Tag tag = (Tag) field.get(clazz);
                if(tag.getId()==id)
                {
                    return tag.getName();
                }
            }
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }
    private static String getStrings( byte[] bs) 
    {
        return new String(bs, 0,bs.length);
    }
    
    private static String getStrings( byte[] bs,int start,int length) 
    {
        return new String(bs, start,length);
    }
    
    private static int getByteToInteger(byte[] bs,int start,int length,boolean isBigEndian)
    {
        byte[] tmpBuf = new byte[]{0,0,0,0};
        if(length==2)
        {
            tmpBuf[2] = bs[start];
            tmpBuf[3] = bs[start+1];
        }else if(length==4){
            tmpBuf[0] = bs[start];
            tmpBuf[1] = bs[start+1];
            tmpBuf[2] = bs[start+2];
            tmpBuf[3] = bs[start+3];
        }
        
        return isBigEndian?bytesToInt(tmpBuf):bytesToIntLitterEndian(tmpBuf);
    }
    
    /**
     * 大端模式
     * @param src
     * @return
     */
    public static int bytesToInt(byte[] src) {  
        int value;    
        int offset = 0;
        value = (int) ( ((src[offset] & 0xFF)<<24)  
                |((src[offset+1] & 0xFF)<<16)  
                |((src[offset+2] & 0xFF)<<8)  
                |(src[offset+3] & 0xFF)); 
        return value;  
    }  
    /**
     * 小端模式
     * @param src
     * @return
     */
    public static int bytesToIntLitterEndian(byte[] src) {  
        int value;    
        int offset = 0;
        value = (int) ( ((src[offset+3] & 0xFF)<<24)  
                |((src[offset+2] & 0xFF)<<16)  
                |((src[offset+1] & 0xFF)<<8)  
                |(src[offset] & 0xFF)); 
        return value;  
    }  
}

辅助类

package com.uap.test;

import java.io.*;

public class Exif {

    public static Tag createTag(int id, String name) {
        return new Tag(id, name);
    }

    public interface Tags {

        public static final Tag Tag_ExifVersion = Exif.createTag(0x9000, "ExifVersion");

        // EXIFversion
        public static final Tag Tag_FlashpixVersion = Exif.createTag(0xA000, "FlashpixVersion");

        // Flashpixformatversion
        public static final Tag Tag_ColorSpace = Exif.createTag(0xA001, "ColorSpace");

        // Colorspaceinformationtag
        public static final Tag Tag_PixelXDimension = Exif.createTag(0xA002, "PixelXDimension");

        // Validwidthofmeaningfulimage
        public static final Tag Tag_PixelYDimension = Exif.createTag(0xA003, "PixelYDimension");

        // Validheightofmeaningfulimage
        public static final Tag Tag_ComponentsConfiguration = Exif.createTag(0x9101, "ComponentsConfiguration");

        // Informationaboutchannels
        public static final Tag Tag_CompressedBitsPerPixel = Exif.createTag(0x9102, "CompressedBitsPerPixel");

        // Compressedbitsperpixel

        public static final Tag Tag_MakerNote = Exif.createTag(0x927C, "MakerNote");

        // Anydesiredinformationwrittenbythemanufacturer
        public static final Tag Tag_UserComment = Exif.createTag(0x9286, "UserComment");

        // Commentsbyuser
        public static final Tag Tag_RelatedSoundFile = Exif.createTag(0xA004, "RelatedSoundFile");

        // Nameofrelatedsoundfile
        public static final Tag Tag_DateTimeOriginal = Exif.createTag(0x9003, "DateTimeOriginal");

        // Dateandtimewhentheoriginalimagewasgenerated

        public static final Tag Tag_DateTimeDigitized = Exif.createTag(0x9004, "DateTimeDigitized");

        // Dateandtimewhentheimagewasstoreddigitally

        public static final Tag Tag_SubsecTime = Exif.createTag(0x9290, "SubsecTime");

        // FractionsofsecondsforDateTime

        public static final Tag Tag_SubsecTimeOriginal = Exif.createTag(0x9291, "SubsecTimeOriginal");

        // FractionsofsecondsforDateTimeOriginal

        public static final Tag Tag_SubsecTimeDigitized = Exif.createTag(0x9292, "SubsecTimeDigitized");

        // FractionsofsecondsforDateTimeDigitized

        public static final Tag Tag_ExposureTime = Exif.createTag(0x829A, "ExposureTime");

        // Exposuretime(inseconds)

        public static final Tag Tag_FNumber = Exif.createTag(0x829D, "FNumber");

        // Fnumber

        public static final Tag Tag_ExposureProgram = Exif.createTag(0x8822, "ExposureProgram");

        // Exposureprogram

        public static final Tag Tag_SpectralSensitivity = Exif.createTag(0x8824, "SpectralSensitivity");

        // Spectralsensitivity

        public static final Tag Tag_ISOSpeedRatings = Exif.createTag(0x8827, "ISOSpeedRatings");

        // ISOspeedrating

        public static final Tag Tag_OECF = Exif.createTag(0x8828, "OECF");

        // Optoelectricconversionfactor

        public static final Tag Tag_ShutterSpeedValue = Exif.createTag(0x9201, "ShutterSpeedValue");

        // Shutterspeed

        public static final Tag Tag_ApertureValue = Exif.createTag(0x9202, "ApertureValue");

        // Lensaperture

        public static final Tag Tag_BrightnessValue = Exif.createTag(0x9203, "BrightnessValue");

        // Valueofbrightness

        public static final Tag Tag_ExposureBias = Exif.createTag(0x9204, "ExposureBias");

        // Exposurebias

        public static final Tag Tag_MaxApertureValue = Exif.createTag(0x9205, "MaxApertureValue");

        // SmallestFnumberoflens

        public static final Tag Tag_SubjectDistance = Exif.createTag(0x9206, "SubjectDistance");

        // Distancetosubjectinmeters

        public static final Tag Tag_MeteringMode = Exif.createTag(0x9207, "MeteringMode");

        // Meteringmode

        public static final Tag Tag_LightSource = Exif.createTag(0x9208, "LightSource");

        // Kindoflightsource

        public static final Tag Tag_Flash = Exif.createTag(0x9209, "Flash");

        // Flashstatus

        public static final Tag Tag_SubjectArea = Exif.createTag(0x9214, "SubjectArea");

        // Locationandareaofmainsubject

        public static final Tag Tag_FocalLength = Exif.createTag(0x920A, "FocalLength");

        // Focallengthofthelensinmm

        public static final Tag Tag_FlashEnergy = Exif.createTag(0xA20B, "FlashEnergy");

        // StrobeenergyinBCPS

        public static final Tag Tag_SpatialFrequencyResponse = Exif.createTag(0xA20C, "SpatialFrequencyResponse");

        public static final Tag Tag_FocalPlaneXResolution = Exif.createTag(0xA20E, "FocalPlaneXResolution");

        // NumberofpixelsinwidthdirectionperFocalPlaneResolutionUnit

        public static final Tag Tag_FocalPlaneYResolution = Exif.createTag(0xA20F, "FocalPlaneYResolution");

        // NumberofpixelsinheightdirectionperFocalPlaneResolutionUnit

        public static final Tag Tag_FocalPlaneResolutionUnit = Exif.createTag(0xA210, "FocalPlaneResolutionUnit");

        // UnitformeasuringFocalPlaneXResolutionandFocalPlaneYResolution

        public static final Tag Tag_SubjectLocation = Exif.createTag(0xA214, "SubjectLocation");

        // Locationofsubjectinimage

        public static final Tag Tag_ExposureIndex = Exif.createTag(0xA215, "ExposureIndex");

        // Exposureindexselectedoncamera

        public static final Tag Tag_SensingMethod = Exif.createTag(0xA217, "SensingMethod");

        // Imagesensortype

        public static final Tag Tag_FileSource = Exif.createTag(0xA300, "FileSource");

        // Imagesource(3DSC)

        public static final Tag Tag_SceneType = Exif.createTag(0xA301, "SceneType");

        // Scenetype(1directlyphotographed)

        public static final Tag Tag_CFAPattern = Exif.createTag(0xA302, "CFAPattern");

        // Colorfilterarraygeometricpattern

        public static final Tag Tag_CustomRendered = Exif.createTag(0xA401, "CustomRendered");

        // Specialprocessing

        public static final Tag Tag_ExposureMode = Exif.createTag(0xA402, "ExposureMode");

        // Exposuremode

        public static final Tag Tag_WhiteBalance = Exif.createTag(0xA403, "WhiteBalance");

        // 1autowhitebalance,2manual

        public static final Tag Tag_DigitalZoomRation = Exif.createTag(0xA404, "DigitalZoomRation");

        // Digitalzoomratio

        public static final Tag Tag_FocalLengthIn35mmFilm = Exif.createTag(0xA405, "FocalLengthIn35mmFilm");

        // Equivalentfoacllengthassuming35mmfilmcamera(inmm)

        public static final Tag Tag_SceneCaptureType = Exif.createTag(0xA406, "SceneCaptureType");

        // Typeofscene

        public static final Tag Tag_GainControl = Exif.createTag(0xA407, "GainControl");

        // Degreeofoverallimagegainadjustment

        public static final Tag Tag_Contrast = Exif.createTag(0xA408, "Contrast");

        // Directionofcontrastprocessingappliedbycamera

        public static final Tag Tag_Saturation = Exif.createTag(0xA409, "Saturation");

        // Directionofsaturationprocessingappliedbycamera

        public static final Tag Tag_Sharpness = Exif.createTag(0xA40A, "Sharpness");

        // Directionofsharpnessprocessingappliedbycamera

        public static final Tag Tag_DeviceSettingDescription = Exif.createTag(0xA40B, "DeviceSettingDescription");

        public static final Tag Tag_SubjectDistanceRange = Exif.createTag(0xA40C, "SubjectDistanceRange");

        // Distancetosubject

        public static final Tag Tag_InteroperabilityIFDPointer = Exif.createTag(0xA005, "InteroperabilityIFDPointer");

        public static final Tag Tag_ImageUniqueID = Exif.createTag(0xA420, "ImageUniqueID");

        // Identifierassigneduniquelytoeachimage

    }

    public interface TiffTags {

        public static final Tag Tag_ImageWidth = Exif.createTag(0x0100, "ImageWidth");

        public static final Tag Tag_ImageHeight = Exif.createTag(0x0101, "ImageHeight");

        public static final Tag Tag_ExifIFDPointer = Exif.createTag(0x8769, "ExifIFDPointer");

        public static final Tag Tag_GPSInfoIFDPointer = Exif.createTag(0x8825, "GPSInfoIFDPointer");

        public static final Tag Tag_InteroperabilityIFDPointer = Exif.createTag(0xA005, "InteroperabilityIFDPointer");

        public static final Tag Tag_BitsPerSample = Exif.createTag(0x0102, "BitsPerSample");

        public static final Tag Tag_Compression = Exif.createTag(0x0103, "Compression");

        public static final Tag Tag_PhotometricInterpretation = Exif.createTag(0x0106, "PhotometricInterpretation");

        public static final Tag Tag_Orientation = Exif.createTag(0x0112, "Orientation");

        public static final Tag Tag_SamplesPerPixel = Exif.createTag(0x0115, "SamplesPerPixel");

        public static final Tag Tag_PlanarConfiguration = Exif.createTag(0x011C, "PlanarConfiguration");

        public static final Tag Tag_YCbCrSubSampling = Exif.createTag(0x0212, "YCbCrSubSampling");

        public static final Tag Tag_YCbCrPositioning = Exif.createTag(0x0213, "YCbCrPositioning");

        public static final Tag Tag_XResolution = Exif.createTag(0x011A, "XResolution");

        public static final Tag Tag_YResolution = Exif.createTag(0x011B, "YResolution");

        public static final Tag Tag_ResolutionUnit = Exif.createTag(0x0128, "ResolutionUnit");

        public static final Tag Tag_StripOffsets = Exif.createTag(0x0111, "StripOffsets");

        public static final Tag Tag_RowsPerStrip = Exif.createTag(0x0116, "RowsPerStrip");

        public static final Tag Tag_StripByteCounts = Exif.createTag(0x0117, "StripByteCounts");

        public static final Tag Tag_JPEGInterchangeFormat = Exif.createTag(0x0201, "JPEGInterchangeFormat");

        public static final Tag Tag_JPEGInterchangeFormatLength = Exif.createTag(0x0202, "JPEGInterchangeFormatLength");

        public static final Tag Tag_TransferFunction = Exif.createTag(0x012D, "TransferFunction");

        public static final Tag Tag_WhitePoint = Exif.createTag(0x013E, "WhitePoint");

        public static final Tag Tag_PrimaryChromaticities = Exif.createTag(0x013F, "PrimaryChromaticities");

        public static final Tag Tag_YCbCrCoefficients = Exif.createTag(0x0211, "YCbCrCoefficients");

        public static final Tag Tag_ReferenceBlackWhite = Exif.createTag(0x0214, "ReferenceBlackWhite");

        public static final Tag Tag_DateTime = Exif.createTag(0x0132, "DateTime");

        public static final Tag Tag_ImageDescription = Exif.createTag(0x010E, "ImageDescription");

        public static final Tag Tag_Make = Exif.createTag(0x010F, "Make");

        public static final Tag Tag_Model = Exif.createTag(0x0110, "Model");

        public static final Tag Tag_Software = Exif.createTag(0x0131, "Software");

        public static final Tag Tag_Artist = Exif.createTag(0x013B, "Artist");

        public static final Tag Tag_Copyright = Exif.createTag(0x8298, "Copyright");

    }

    public interface GPSTags {

        public static final Tag Tag_GPSVersionID = Exif.createTag(0x0000, "GPSVersionID");

        public static final Tag Tag_GPSLatitudeRef = Exif.createTag(0x0001, "GPSLatitudeRef");

        public static final Tag Tag_GPSLatitude = Exif.createTag(0x0002, "GPSLatitude");

        public static final Tag Tag_GPSLongitudeRef = Exif.createTag(0x0003, "GPSLongitudeRef");

        public static final Tag Tag_GPSLongitude = Exif.createTag(0x0004, "GPSLongitude");

        public static final Tag Tag_GPSAltitudeRef = Exif.createTag(0x0005, "GPSAltitudeRef");

        public static final Tag Tag_GPSAltitude = Exif.createTag(0x0006, "GPSAltitude");

        public static final Tag Tag_GPSTimeStamp = Exif.createTag(0x0007, "GPSTimeStamp");

        public static final Tag Tag_GPSSatellites = Exif.createTag(0x0008, "GPSSatellites");

        public static final Tag Tag_GPSStatus = Exif.createTag(0x0009, "GPSStatus");

        public static final Tag Tag_GPSMeasureMode = Exif.createTag(0x000A, "GPSMeasureMode");

        public static final Tag Tag_GPSDOP = Exif.createTag(0x000B, "GPSDOP");

        public static final Tag Tag_GPSSpeedRef = Exif.createTag(0x000C, "GPSSpeedRef");

        public static final Tag Tag_GPSSpeed = Exif.createTag(0x000D, "GPSSpeed");

        public static final Tag Tag_GPSTrackRef = Exif.createTag(0x000E, "GPSTrackRef");

        public static final Tag Tag_GPSTrack = Exif.createTag(0x000F, "GPSTrack");

        public static final Tag Tag_GPSImgDirectionRef = Exif.createTag(0x0010, "GPSImgDirectionRef");

        public static final Tag Tag_GPSImgDirection = Exif.createTag(0x0011, "GPSImgDirection");

        public static final Tag Tag_GPSMapDatum = Exif.createTag(0x0012, "GPSMapDatum");

        public static final Tag Tag_GPSDestLatitudeRef = Exif.createTag(0x0013, "GPSDestLatitudeRef");

        public static final Tag Tag_GPSDestLatitude = Exif.createTag(0x0014, "GPSDestLatitude");

        public static final Tag Tag_GPSDestLongitudeRef = Exif.createTag(0x0015, "GPSDestLongitudeRef");

        public static final Tag Tag_GPSDestLongitude = Exif.createTag(0x0016, "GPSDestLongitude");

        public static final Tag Tag_GPSDestBearingRef = Exif.createTag(0x0017, "GPSDestBearingRef");

        public static final Tag Tag_GPSDestBearing = Exif.createTag(0x0018, "GPSDestBearing");

        public static final Tag Tag_GPSDestDistanceRef = Exif.createTag(0x0019, "GPSDestDistanceRef");

        public static final Tag Tag_GPSDestDistance = Exif.createTag(0x001A, "GPSDestDistance");

        public static final Tag Tag_GPSProcessingMethod = Exif.createTag(0x001B, "GPSProcessingMethod");

        public static final Tag Tag_GPSAreaInformation = Exif.createTag(0x001C, "GPSAreaInformation");

        public static final Tag Tag_GPSDateStamp = Exif.createTag(0x001D, "GPSDateStamp");

        public static final Tag Tag_GPSDifferential = Exif.createTag(0x001E, "GPSDifferential");

    }

    public interface StringValues {

        public interface ExposureProgram {

            public static final Tag Tag_Notdefined = Exif.createTag(0, "Notdefined");

            public static final Tag Tag_Manual = Exif.createTag(1, "Manual");

            public static final Tag Tag_Normalprogram = Exif.createTag(2, "Normalprogram");

            public static final Tag Tag_Aperturepriority = Exif.createTag(3, "Aperturepriority");

            public static final Tag Tag_Shutterpriority = Exif.createTag(4, "Shutterpriority");

            public static final Tag Tag_Creativeprogram = Exif.createTag(5, "Creativeprogram");

            public static final Tag Tag_Actionprogram = Exif.createTag(6, "Actionprogram");

            public static final Tag Tag_Portraitmode = Exif.createTag(7, "Portraitmode");

            public static final Tag Tag_Landscapemode = Exif.createTag(8, "Landscapemode");

        }

        public interface MeteringMode {

            public static final Tag Tag_Unknown = Exif.createTag(0, "Unknown");

            public static final Tag Tag_Average = Exif.createTag(1, "Average");

            public static final Tag Tag_CenterWeightedAverage = Exif.createTag(2, "CenterWeightedAverage");

            public static final Tag Tag_Spot = Exif.createTag(3, "Spot");

            public static final Tag Tag_MultiSpot = Exif.createTag(4, "MultiSpot");

            public static final Tag Tag_Pattern = Exif.createTag(5, "Pattern");

            public static final Tag Tag_Partial = Exif.createTag(6, "Partial");

            public static final Tag Tag_Other = Exif.createTag(255, "Other");

        }

        public interface LightSource {

            public static final Tag Tag_Unknown = Exif.createTag(0, "Unknown");

            public static final Tag Tag_Daylight = Exif.createTag(1, "Daylight");

            public static final Tag Tag_Fluorescent = Exif.createTag(2, "Fluorescent");

            public static final Tag Tag_Tungstenincandescentlight = Exif.createTag(3, "Tungstenincandescentlight");

            public static final Tag Tag_Flash = Exif.createTag(4, "Flash");

            public static final Tag Tag_Fineweather = Exif.createTag(9, "Fineweather");

            public static final Tag Tag_Cloudyweather = Exif.createTag(10, "Cloudyweather");

            public static final Tag Tag_Shade = Exif.createTag(11, "Shade");

            public static final Tag Tag_DaylightfluorescentD57007100K = Exif.createTag(12,
                    "DaylightfluorescentD57007100K");

            public static final Tag Tag_DaywhitefluorescentN46005400K = Exif.createTag(13,
                    "DaywhitefluorescentN46005400K");

            public static final Tag Tag_CoolwhitefluorescentW39004500K = Exif.createTag(14,
                    "CoolwhitefluorescentW39004500K");

            public static final Tag Tag_WhitefluorescentWW32003700K = Exif.createTag(15, "WhitefluorescentWW32003700K");

            public static final Tag Tag_StandardlightA = Exif.createTag(17, "StandardlightA");

            public static final Tag Tag_StandardlightB = Exif.createTag(18, "StandardlightB");

            public static final Tag Tag_StandardlightC = Exif.createTag(19, "StandardlightC");

            public static final Tag Tag_D55 = Exif.createTag(20, "D55");

            public static final Tag Tag_D65 = Exif.createTag(21, "D65");

            public static final Tag Tag_D75 = Exif.createTag(22, "D75");

            public static final Tag Tag_D50 = Exif.createTag(23, "D50");

            public static final Tag Tag_ISOstudiotungsten = Exif.createTag(24, "ISOstudiotungsten");

            public static final Tag Tag_Other = Exif.createTag(255, "Other");

        }

        public interface Flash {

            public static final Tag Tag_Flashdidnotfire = Exif.createTag(0x0000, "Flashdidnotfire");

            public static final Tag Tag_Flashfired = Exif.createTag(0x0001, "Flashfired");

            public static final Tag Tag_Strobereturnlightnotdetected = Exif.createTag(0x0005,
                    "Strobereturnlightnotdetected");

            public static final Tag Tag_Strobereturnlightdetected = Exif.createTag(0x0007, "Strobereturnlightdetected");

            public static final Tag Tag_Flashfiredcompulsoryflashmode = Exif.createTag(0x0009,
                    "Flashfiredcompulsoryflashmode");

            public static final Tag Tag_Flashfiredcompulsoryflashmodereturnlightnotdetected = Exif.createTag(0x000D,
                    "Flashfiredcompulsoryflashmodereturnlightnotdetected");

            public static final Tag Tag_Flashfiredcompulsoryflashmodereturnlightdetected = Exif.createTag(0x000F,
                    "Flashfiredcompulsoryflashmodereturnlightdetected");

            public static final Tag Tag_Flashdidnotfirecompulsoryflashmode = Exif.createTag(0x0010,
                    "Flashdidnotfirecompulsoryflashmode");

            public static final Tag Tag_Flashdidnotfireautomode = Exif.createTag(0x0018, "Flashdidnotfireautomode");

            public static final Tag Tag_Flashfiredautomode = Exif.createTag(0x0019, "Flashfiredautomode");

            public static final Tag Tag_Flashfiredautomodereturnlightnotdetected = Exif.createTag(0x001D,
                    "Flashfiredautomodereturnlightnotdetected");

            public static final Tag Tag_Flashfiredautomodereturnlightdetected = Exif.createTag(0x001F,
                    "Flashfiredautomodereturnlightdetected");

            public static final Tag Tag_Noflashfunction = Exif.createTag(0x0020, "Noflashfunction");

            public static final Tag Tag_Flashfiredredeyereductionmode = Exif.createTag(0x0041,
                    "Flashfiredredeyereductionmode");

            public static final Tag Tag_Flashfiredredeyereductionmodereturnlightnotdetected = Exif.createTag(0x0045,
                    "Flashfiredredeyereductionmodereturnlightnotdetected");

            public static final Tag Tag_Flashfiredredeyereductionmodereturnlightdetected = Exif.createTag(0x0047,
                    "Flashfiredredeyereductionmodereturnlightdetected");

            public static final Tag Tag_Flashfiredcompulsoryflashmoderedeyereductionmode = Exif.createTag(0x0049,
                    "Flashfiredcompulsoryflashmoderedeyereductionmode");

            public static final Tag Tag_Flashfiredcompulsoryflashmoderedeyereductionmodereturnlightnotdetected = Exif
                    .createTag(0x004D, "Flashfiredcompulsoryflashmoderedeyereductionmodereturnlightnotdetected");

            public static final Tag Tag_Flashfiredcompulsoryflashmoderedeyereductionmodereturnlightdetected = Exif
                    .createTag(0x004F, "Flashfiredcompulsoryflashmoderedeyereductionmodereturnlightdetected");

            public static final Tag Tag_Flashfiredautomoderedeyereductionmode = Exif.createTag(0x0059,
                    "Flashfiredautomoderedeyereductionmode");

            public static final Tag Tag_Flashfiredautomodereturnlightnotdetectedredeyereductionmode = Exif
                    .createTag(0x005D, "Flashfiredautomodereturnlightnotdetectedredeyereductionmode");

            public static final Tag Tag_Flashfiredautomodereturnlightdetectedredeyereductionmode = Exif
                    .createTag(0x005F, "Flashfiredautomodereturnlightdetectedredeyereductionmode");

        }

        public interface SensingMethod {

            public static final Tag Tag_Notdefined = Exif.createTag(1, "Notdefined");

            public static final Tag Tag_Onechipcolorareasensor = Exif.createTag(2, "Onechipcolorareasensor");

            public static final Tag Tag_Twochipcolorareasensor = Exif.createTag(3, "Twochipcolorareasensor");

            public static final Tag Tag_Threechipcolorareasensor = Exif.createTag(4, "Threechipcolorareasensor");

            public static final Tag Tag_Colorsequentialareasensor = Exif.createTag(5, "Colorsequentialareasensor");

            public static final Tag Tag_Trilinearsensor = Exif.createTag(7, "Trilinearsensor");

            public static final Tag Tag_Colorsequentiallinearsensor = Exif.createTag(8, "Colorsequentiallinearsensor");

        }

        public interface SceneCaptureType {

            public static final Tag Tag_Standard = Exif.createTag(0, "Standard");

            public static final Tag Tag_Landscape = Exif.createTag(1, "Landscape");

            public static final Tag Tag_Portrait = Exif.createTag(2, "Portrait");

            public static final Tag Tag_Nightscene = Exif.createTag(3, "Nightscene");

        }

        public interface SceneType {

            public static final Tag Tag_Directlyphotographed = Exif.createTag(1, "Directlyphotographed");

        }

        public interface CustomRendered {

            public static final Tag Tag_Normalprocess = Exif.createTag(0, "Normalprocess");

            public static final Tag Tag_Customprocess = Exif.createTag(1, "Customprocess");

        }

        public interface WhiteBalance {

            public static final Tag Tag_Autowhitebalance = Exif.createTag(0, "Autowhitebalance");

            public static final Tag Tag_Manualwhitebalance = Exif.createTag(1, "Manualwhitebalance");

        }

        public interface GainControl {

            public static final Tag Tag_None = Exif.createTag(0, "None");

            public static final Tag Tag_Lowgainup = Exif.createTag(1, "Lowgainup");

            public static final Tag Tag_Highgainup = Exif.createTag(2, "Highgainup");

            public static final Tag Tag_Lowgaindown = Exif.createTag(3, "Lowgaindown");

            public static final Tag Tag_Highgaindown = Exif.createTag(4, "Highgaindown");

        }

        public interface Contrast {

            public static final Tag Tag_Normal = Exif.createTag(0, "Normal");

            public static final Tag Tag_Soft = Exif.createTag(1, "Soft");

            public static final Tag Tag_Hard = Exif.createTag(2, "Hard");

        }

        public interface Saturation {

            public static final Tag Tag_Normal = Exif.createTag(0, "Normal");

            public static final Tag Tag_Lowsaturation = Exif.createTag(1, "Lowsaturation");

            public static final Tag Tag_Highsaturation = Exif.createTag(2, "Highsaturation");

        }

        public interface Sharpness {

            public static final Tag Tag_Normal = Exif.createTag(0, "Normal");

            public static final Tag Tag_Soft = Exif.createTag(1, "Soft");

            public static final Tag Tag_Hard = Exif.createTag(2, "Hard");

        }

        public interface SubjectDistanceRange {

            public static final Tag Tag_Unknown = Exif.createTag(0, "Unknown");

            public static final Tag Tag_Macro = Exif.createTag(1, "Macro");

            public static final Tag Tag_Closeview = Exif.createTag(2, "Closeview");

            public static final Tag Tag_Distantview = Exif.createTag(3, "Distantview");

        }

        public interface FileSource {

            public static final Tag Tag_DSC = Exif.createTag(3, "DSC");

        }

        public interface Components {

            public static final Tag Tag_ = Exif.createTag(0, "");

            public static final Tag Tag_Y = Exif.createTag(1, "Y");

            public static final Tag Tag_Cb = Exif.createTag(2, "Cb");

            public static final Tag Tag_Cr = Exif.createTag(3, "Cr");

            public static final Tag Tag_R = Exif.createTag(4, "R");

            public static final Tag Tag_G = Exif.createTag(5, "G");

            public static final Tag Tag_B = Exif.createTag(6, "B");

        }

    }

}
点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
5个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Castle85 Castle85
3年前
.net c#通过Exif获取图片信息(参数)
.netc通过Exif获取图片信息(参数).netc通过Exif获取图片信息(参数)简介   想要获取图片的信息,例如快门速度、ISO值等等,我们可以通过读取Exif中存储的
Wesley13 Wesley13
3年前
Java日期时间API系列31
  时间戳是指格林威治时间1970年01月01日00时00分00秒起至现在的总毫秒数,是所有时间的基础,其他时间可以通过时间戳转换得到。Java中本来已经有相关获取时间戳的方法,Java8后增加新的类Instant等专用于处理时间戳问题。 1获取时间戳的方法和性能对比1.1获取时间戳方法Java8以前
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
3年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
11个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这