reading android jpeg EXIF metadata from picture callback

前端 未结 8 1823
天命终不由人
天命终不由人 2020-11-30 20:48

Background: I am writing a camera app for a messenger program. I cannot save the captured image to persistent disk at any time. The camera must support all orientations.

8条回答
  •  渐次进展
    2020-11-30 21:29

    For anybody who might be interested, here is how to get the Orientation tag using the 2.3.1 interface from https://github.com/strangecargo/metadata-extractor

    Metadata header;
    try {
        ByteArrayInputStream bais= new ByteArrayInputStream(data);
        ExifReader reader = new ExifReader(bais);
        header = reader.extract();
        Directory dir = header.getDirectory(ExifDirectory.class);
        if (dir.containsTag(ExifDirectory.TAG_ORIENTATION)) {
            Log.v(TAG, "tag_orientation exists: " + dir.getInt(ExifDirectory.TAG_ORIENTATION));
        }
        else {
            Log.v(TAG, "tag_orietation doesn't exist");
        }
    
    
    } catch (JpegProcessingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MetadataException e) {
        e.printStackTrace();
    }
    

提交回复
热议问题