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


Java ExifInterface类代码示例

本文整理汇总了Java中android.media.ExifInterface的典型用法代码示例。如果您正苦于以下问题:Java ExifInterface类的具体用法?Java ExifInterface怎么用?Java ExifInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: readPictureDegree

import android.media.ExifInterface; //导入依赖的package包/类
/**
 * 读取图片属性:旋转的角度
 * @param path 图片绝对路径
 * @return degree旋转的角度
 */
public static int readPictureDegree(String path) {
    int degree  = 0;
    try {
        ExifInterface exifInterface = new ExifInterface(path);
        int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                degree = 90;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                degree = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                degree = 270;
                break;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return degree;
}
 
开发者ID:StickyTolt,项目名称:ForeverLibrary,代码行数:27,代码来源:Utils.java

示例2: getRotateDegree

import android.media.ExifInterface; //导入依赖的package包/类
/**
 * 获取图片旋转角度
 *
 * @param filePath 文件路径
 * @return 旋转角度
 */
public static int getRotateDegree(String filePath) {
    int degree = 0;
    try {
        ExifInterface exifInterface = new ExifInterface(filePath);
        int orientation = exifInterface.getAttributeInt(
                ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
            default:
            case ExifInterface.ORIENTATION_ROTATE_90:
                degree = 90;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                degree = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                degree = 270;
                break;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return degree;
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:31,代码来源:ImageUtils.java

示例3: getImageDegrees

import android.media.ExifInterface; //导入依赖的package包/类
public static int getImageDegrees(String pathName) {
    int degrees = 0;
    try {
        ExifInterface exifInterface = new ExifInterface(pathName);
        int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                degrees = 90;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                degrees = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                degrees = 270;
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return degrees;
}
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:23,代码来源:ImageUtils.java

示例4: readDegree

import android.media.ExifInterface; //导入依赖的package包/类
/**
 * Read the rotation angle of the picture file.
 *
 * @param path image path.
 * @return one of 0, 90, 180, 270.
 */
public static int readDegree(String path) {
    try {
        ExifInterface exifInterface = new ExifInterface(path);
        int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        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;
        }
    } catch (Exception e) {
        return 0;
    }
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:25,代码来源:DefaultAlbumLoader.java

示例5: copyExif

import android.media.ExifInterface; //导入依赖的package包/类
private static void copyExif(Context context, Uri oldImage, File newFile) throws IOException {
  File oldFile = getFileFromUri(context, oldImage);
  if (oldFile == null) {
    FLog.w(ReactConstants.TAG, "Couldn't get real path for uri: " + oldImage);
    return;
  }

  ExifInterface oldExif = new ExifInterface(oldFile.getAbsolutePath());
  ExifInterface newExif = new ExifInterface(newFile.getAbsolutePath());
  for (String attribute : EXIF_ATTRIBUTES) {
    String value = oldExif.getAttribute(attribute);
    if (value != null) {
      newExif.setAttribute(attribute, value);
    }
  }
  newExif.saveAttributes();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:ImageEditingManager.java

示例6: readRotation

import android.media.ExifInterface; //导入依赖的package包/类
/**
 * Parses the rotation of the JPEG image.
 */
public static int readRotation(String filePath) {
    try {
        ExifInterface exif = new ExifInterface(filePath);
        switch (exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0)) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                return 90;
            case ExifInterface.ORIENTATION_ROTATE_270:
                return 270;
            case ExifInterface.ORIENTATION_ROTATE_180:
                return 180;
            default:
                return 0;
        }
    } catch (IOException e) {
        if (DEBUG) {
            Log.d(TAG, "Error reading file", e);
        }
    }
    return 0;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:24,代码来源:ExifOrientation.java

示例7: getOrientation

import android.media.ExifInterface; //导入依赖的package包/类
public static int getOrientation(final String imagePath) {
    int rotate = 0;
    try {
        File imageFile = new File(imagePath);
        ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface
                .ORIENTATION_NORMAL);
        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_270:
                rotate = 270;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                rotate = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_90:
                rotate = 90;
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return rotate;
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:24,代码来源:BitmapUtils.java

示例8: extractExifInfo

import android.media.ExifInterface; //导入依赖的package包/类
public static void extractExifInfo(MediaDetails details, String filePath) {
    try {
        ExifInterface exif = new ExifInterface(filePath);
        setExifData(details, exif, ExifInterface.TAG_FLASH, MediaDetails.INDEX_FLASH);
        setExifData(details, exif, ExifInterface.TAG_IMAGE_WIDTH, MediaDetails.INDEX_WIDTH);
        setExifData(details, exif, ExifInterface.TAG_IMAGE_LENGTH,
                MediaDetails.INDEX_HEIGHT);
        setExifData(details, exif, ExifInterface.TAG_MAKE, MediaDetails.INDEX_MAKE);
        setExifData(details, exif, ExifInterface.TAG_MODEL, MediaDetails.INDEX_MODEL);
        setExifData(details, exif, ExifInterface.TAG_APERTURE, MediaDetails.INDEX_APERTURE);
        setExifData(details, exif, ExifInterface.TAG_ISO, MediaDetails.INDEX_ISO);
        setExifData(details, exif, ExifInterface.TAG_WHITE_BALANCE,
                MediaDetails.INDEX_WHITE_BALANCE);
        setExifData(details, exif, ExifInterface.TAG_EXPOSURE_TIME,
                MediaDetails.INDEX_EXPOSURE_TIME);
        double data = exif.getAttributeDouble(ExifInterface.TAG_FOCAL_LENGTH, 0);
        if (data != 0f) {
            details.addDetail(MediaDetails.INDEX_FOCAL_LENGTH, data);
            details.setUnit(MediaDetails.INDEX_FOCAL_LENGTH, R.string.unit_mm);
        }
    } catch (IOException ex) {
        // ignore it.
        Log.w(TAG, "", ex);
    }
}
 
开发者ID:mayurkaul,项目名称:medialibrary,代码行数:26,代码来源:MediaDetails.java

示例9: getRotateDegree

import android.media.ExifInterface; //导入依赖的package包/类
static int getRotateDegree(String path) {
    int result = 0;
    try {
        ExifInterface exif = new ExifInterface(path);
        int orientation = exif.getAttributeInt(
                ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                result = 90;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                result = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                result = 270;
                break;
        }
    } catch (IOException ignore) {
        return 0;
    }
    return result;
}
 
开发者ID:Bilibili,项目名称:boxing,代码行数:24,代码来源:BoxingExifHelper.java

示例10: onDecodeOriginal

import android.media.ExifInterface; //导入依赖的package包/类
@Override
public Bitmap onDecodeOriginal(ThreadPool.JobContext jc, final int type) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    int targetSize = MediaItem.getTargetSize(type);

    // try to decode from JPEG EXIF
    if (type == MediaItem.TYPE_MICROTHUMBNAIL) {
        byte[] thumbData = null;
        try {
            ExifInterface exif = new ExifInterface(mLocalFilePath);
            thumbData = exif.getThumbnail();
        } catch (IOException e) {
            Log.w(TAG, "failed to find file to read thumbnail: " + mLocalFilePath);
        }
        if (thumbData != null) {
            Bitmap bitmap = DecodeUtils.decodeIfBigEnough(
                    jc, thumbData, options, targetSize);
            if (bitmap != null) return bitmap;
        }
    }

    return DecodeUtils.decodeThumbnail(jc, mLocalFilePath, options, targetSize, type);
}
 
开发者ID:mayurkaul,项目名称:medialibrary,代码行数:25,代码来源:LocalImage.java

示例11: getRotateDegrees

import android.media.ExifInterface; //导入依赖的package包/类
/**
 * 获取图片的旋转角度
 *
 * @param imgPath 图片路径
 * @return 0,90,180,270
 */
public static int getRotateDegrees(String imgPath) {
    int degrees = 0;
    try {
        ExifInterface exif = new ExifInterface(imgPath);
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                degrees = 90;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                degrees = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                degrees = 270;
                break;
            default:
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return degrees;
}
 
开发者ID:sundevin,项目名称:utilsLibrary,代码行数:32,代码来源:BitmapUtils.java

示例12: getPictureDegree

import android.media.ExifInterface; //导入依赖的package包/类
/**
 * 获取图片的旋转角度
 * http://www.eoeandroid.com/thread-196978-1-1.html
 * @param path 照片路径
 * @return
 */
public static int getPictureDegree(String path) {
	int degree = 0;
	try {
		// 从指定路径下读取图片,并获取其EXIF信息
		ExifInterface exifInterface = new ExifInterface(path);
		// 获取图片的旋转信息
		int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
		switch (orientation) {
			case ExifInterface.ORIENTATION_ROTATE_90:
				degree = 90;
				break;
			case ExifInterface.ORIENTATION_ROTATE_180:
				degree = 180;
				break;
			case ExifInterface.ORIENTATION_ROTATE_270:
				degree = 270;
				break;
		}
	} catch (IOException e) {
		e.printStackTrace();
	}
	return degree;

}
 
开发者ID:CoderCF,项目名称:TakePhoto,代码行数:31,代码来源:FileUtil.java

示例13: getExifRotation

import android.media.ExifInterface; //导入依赖的package包/类
public static int getExifRotation(File imageFile) {
    if (imageFile == null) return 0;
    try {
        ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
        // We only recognize a subset of orientation tag values
        switch (exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED)) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                return 90;
            case ExifInterface.ORIENTATION_ROTATE_180:
                return 180;
            case ExifInterface.ORIENTATION_ROTATE_270:
                return 270;
            default:
                return ExifInterface.ORIENTATION_UNDEFINED;
        }
    } catch (IOException e) {
        return 0;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:CropUtil.java

示例14: getExifRotateDegrees

import android.media.ExifInterface; //导入依赖的package包/类
private static int getExifRotateDegrees(int exifOrientation) {
    int degrees = 0;
    switch (exifOrientation) {
        case ExifInterface.ORIENTATION_NORMAL:
            degrees = 0;
            break;
        case ExifInterface.ORIENTATION_ROTATE_90:
            degrees = 90;
            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            degrees = 180;
            break;
        case ExifInterface.ORIENTATION_ROTATE_270:
            degrees = 270;
            break;
    }
    return degrees;
}
 
开发者ID:zhouzhuo810,项目名称:CameraCardCropDemo,代码行数:19,代码来源:BitmapUtils.java

示例15: rotate

import android.media.ExifInterface; //导入依赖的package包/类
@Override
public void rotate(int degrees) throws Exception {
    GalleryUtils.assertNotInRenderThread();
    Uri baseUri = Images.Media.EXTERNAL_CONTENT_URI;
    ContentValues values = new ContentValues();
    int rotation = (this.rotation + degrees) % 360;
    if (rotation < 0) rotation += 360;

    if (mimeType.equalsIgnoreCase("image/jpeg")) {
        ExifInterface exifInterface = new ExifInterface(filePath);
        exifInterface.setAttribute(ExifInterface.TAG_ORIENTATION,
                String.valueOf(rotation));
        exifInterface.saveAttributes();
        fileSize = new File(filePath).length();
        values.put(Images.Media.SIZE, fileSize);
    }

    values.put(Images.Media.ORIENTATION, rotation);
    mApplication.getContentResolver().update(baseUri, values, "_id=?",
            new String[]{String.valueOf(id)});
}
 
开发者ID:mayurkaul,项目名称:medialibrary,代码行数:22,代码来源:LocalImage.java


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