Android ExifInterface - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ExifInterface class.

This code example shows how to use the following methods:getAttribute
    } 
 
    public static int getExifRotation(String imgPath) {
    	int rotate = 0;
        try { 
            ExifInterface exif = new ExifInterface(imgPath);
            String rotationAmount = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
            if (!TextUtils.isEmpty(rotationAmount)) {
                int rotationParam = Integer.parseInt(rotationAmount);
                switch (rotationParam) {
                case ExifInterface.ORIENTATION_NORMAL:
                	rotate = 0;
                	break; 
                case ExifInterface.ORIENTATION_ROTATE_90:
                	rotate = 90;
                	break; 
                case ExifInterface.ORIENTATION_ROTATE_180:
                	rotate = 180;
                	break; 
                case ExifInterface.ORIENTATION_ROTATE_270:
8
CodeRank
This code example shows how to use the following methods:getAttributeInt
			cursor.close();
			int rotation = 0;
			 
			try 
			{ 
				ExifInterface exifInterface = new ExifInterface(filepath);
				int exifRotation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,ExifInterface.ORIENTATION_UNDEFINED);
 
				if(exifRotation!=ExifInterface.ORIENTATION_UNDEFINED)
				{ 
					switch(exifRotation)
					{ 
						case ExifInterface.ORIENTATION_ROTATE_180 :
							rotation = 180;
							break; 
						case ExifInterface.ORIENTATION_ROTATE_270 :
							rotation = 270;
							break; 
						case ExifInterface.ORIENTATION_ROTATE_90 :
							rotation = 90;
6
CodeRank
This code example shows how to use the following methods:getAttributeInt
	 
	public static int getExifOrientation(String filepath) {
		int degree = 0;
		ExifInterface exif = null;
		try { 
			exif = new ExifInterface(filepath);
		} catch (IOException ex) {
			ex.printStackTrace();
		} 
		if (exif != null) {
			int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
			if (orientation != -1) {
				// We only recognise a subset of orientation tag values. 
				switch (orientation) {
				case ExifInterface.ORIENTATION_ROTATE_90:
					degree = 90;
					break; 
				case ExifInterface.ORIENTATION_ROTATE_180:
					degree = 180;
					break; 
7
CodeRank
This code example shows how to use the following methods:getAttributeInt
     * @return 
     * @throws IOException 
     */ 
    public static int getOrientationInDegreesForFileName(String fileName) throws IOException
    { 
        ExifInterface exif = new ExifInterface(fileName);
        int rotation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        int rotationInDegrees = exifToDegrees(rotation);
        return rotationInDegrees;
    } 
 
    /** 
     * Convert exif orientation information to degrees. 
     * Idea and code taken from http://stackoverflow.com/a/11081918/527759 
     *  
     * @param exifOrientation 
     * @return 
     */ 
    private static int exifToDegrees(int exifOrientation) {
7
CodeRank
This code example shows how to use the following methods:saveAttributes, setAttribute
     */ 
    public void replaceExifTag(String tag, String value) {
        if (mExif == null) {
            loadExifData(); 
        } 
        mExif.setAttribute(tag, value);
    } 
 
    private void loadExifData() { 
        try { 
            mExif = new ExifInterface(mDataPath);
        } catch (IOException ex) {
            Log.e(TAG, "cannot read exif", ex);
        } 
    } 
 
    private void saveExifData() throws IOException { 
        if (mExif != null) {
            mExif.saveAttributes();
        } 

6
CodeRank
This code example shows how to use the following methods:getAttributeInt
		options.inSampleSize = 4;
 
		Bitmap bitmap = BitmapFactory.decodeFile(_path, options);
 
		try { 
			ExifInterface exif = new ExifInterface(_path);
			int exifOrientation = exif.getAttributeInt(
					ExifInterface.TAG_ORIENTATION,
					ExifInterface.ORIENTATION_NORMAL);
 
			Log.v(TAG, "Orient: " + exifOrientation);
 
			int rotate = 0;
 
			switch (exifOrientation) {
			case ExifInterface.ORIENTATION_ROTATE_90:
				rotate = 90;
				break; 
			case ExifInterface.ORIENTATION_ROTATE_180:
				rotate = 180;
6
CodeRank
This code example shows how to use the following methods:getAttribute, saveAttributes, setAttribute
            seconds = secnds[0];
        String longitudeStr = splits[0] + "/1," + splits[1] + "/1," + seconds + "/1";
    	 
    	// Setting the location 
    	try { 
			ExifInterface exif = new ExifInterface(path);
 
			System.out.println("Converted latitude: " + latitudeStr);
			exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, latitudeStr);
            exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, latitude>0?"N":"S");
             
            System.out.println("Converted longitude: " + longitudeStr);
            exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, longitudeStr);
            exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, longitude>0?"E":"W");
 
            // Save the changes 
			exif.saveAttributes();
			  
			// Checking if it get set 
			String exifLAT = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);

6
CodeRank
This code example shows how to use the following methods:getAttribute
This code example shows how to use the following methods:getAttribute
			if (resultCode == RESULT_OK) {
				switch(requestCode){
				case REQUEST_CODE_CAMERA:
					Log.d("tempURL",photoUri.toString());			
					imageView.setImageBitmap(uri2bmp(this, photoUri, (int)(280 * IMAGE_SCALE), (int)(280 * IMAGE_SCALE)));
					ExifInterface ei = new ExifInterface(photoUri.toString());
					Log.d("EXIF",ei.getAttribute(ExifInterface.TAG_DATETIME));
					Log.d("EXIF",ei.getAttribute(ExifInterface.TAG_FLASH));
					Log.d("EXIF",ei.getAttribute(ExifInterface.TAG_GPS_LATITUDE));
					Log.d("EXIF",ei.getAttribute(ExifInterface.TAG_GPS_LONGITUDE));
					Log.d("EXIF",ei.getAttribute(ExifInterface.TAG_IMAGE_LENGTH));
					Log.d("EXIF",ei.getAttribute(ExifInterface.TAG_IMAGE_WIDTH));
					break; 
				default: 
					break; 
			} 
		} 
	} catch (OutOfMemoryError e) {
		//Toast.makeText(this, getString(R.string.notify_out_of_memory), Toast.LENGTH_SHORT).show(); 
		System.gc();
6
CodeRank
This code example shows how to use the following methods:getAttributeInt
        } 
    } 
 
    public int getPictureRotation() throws IOException { 
        ExifInterface exif = getExifInterface();
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
 
        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                return 90; 
            case ExifInterface.ORIENTATION_ROTATE_180:
                return 180; 
            case ExifInterface.ORIENTATION_ROTATE_270:
                return 270; 
            default: 
                return 0; 
        } 
    } 
 
    protected ExifInterface getExifInterface() throws IOException {

6
CodeRank

Related Android ExifInterface Questions & Answers:

See Code Examples for Android ExifInterface Methods: