/** * 读取图片属性:旋转的角度 * @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; }
/** * 获取图片旋转角度 * * @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; }
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; }
/** * 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; } }
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(); }
/** * 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; }
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; }
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); } }
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; }
@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); }
/** * 获取图片的旋转角度 * * @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; }
/** * 获取图片的旋转角度 * 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; }
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; } }
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; }
@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)}); }
/** * 获取图片旋转角度 * * @param filePath 文件路径 * @return 旋转角度 */ public static int getRotateDegree(final 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; }
/** * 读取图片的旋转的角度 * * @param path 图片绝对路径 * @return 图片的旋转角度 */ private int getBitmapDegree(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; }
private 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; }
private 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; }
/** * 读取图片属性:旋转的角度 * @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; }
@Override protected int getPhotoOrientation(@Configuration.SensorPosition int sensorPosition) { final int rotate; if (currentCameraId.equals(faceFrontCameraId)) { rotate = (360 + faceFrontCameraOrientation + configurationProvider.getDegrees()) % 360; } else { rotate = (360 + faceBackCameraOrientation - configurationProvider.getDegrees()) % 360; } if (rotate == 0) { orientation = ExifInterface.ORIENTATION_NORMAL; } else if (rotate == 90) { orientation = ExifInterface.ORIENTATION_ROTATE_90; } else if (rotate == 180) { orientation = ExifInterface.ORIENTATION_ROTATE_180; } else if (rotate == 270) { orientation = ExifInterface.ORIENTATION_ROTATE_270; } return orientation; }
/** * 读取图片的旋转的角度 * * @param path 图片绝对路径 * @return 图片的旋转角度 */ public static int getBitmapDegree(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; }
/** * 读取图片文件旋转的角度 * * @param path 图片绝对路径 * @return 图片旋转的角度 */ public static int getPicRotate(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; }
private void writeLocationExifData(ReadableMap options, ExifInterface exif) { if(!options.hasKey("metadata")) return; ReadableMap metadata = options.getMap("metadata"); if (!metadata.hasKey("location")) return; ReadableMap location = metadata.getMap("location"); if(!location.hasKey("coords")) return; try { ReadableMap coords = location.getMap("coords"); double latitude = coords.getDouble("latitude"); double longitude = coords.getDouble("longitude"); GPS.writeExifData(latitude, longitude, exif); } catch (IOException e) { Log.e(TAG, "Couldn't write location data", e); } }
/** * Rotate the given image by given Exif value.<br> * If no rotation is required the image will not be rotated.<br> * New bitmap is created and the old one is recycled. */ static RotateBitmapResult rotateBitmapByExif(Bitmap bitmap, ExifInterface exif) { int degrees; 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: degrees = 0; break; } return new RotateBitmapResult(bitmap, degrees); }
private int getOrientationFromExifInterface(Uri uri) { try { ExifInterface exif = new ExifInterface(uri.getPath()); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: return 270; case ExifInterface.ORIENTATION_ROTATE_180: return 180; case ExifInterface.ORIENTATION_ROTATE_90: return 90; case ExifInterface.ORIENTATION_NORMAL: return 0; default: return -1; } } catch (IOException e) { return -1; } }
@Test public void testWidthAndHeightWithInvertedOrientationImage() { // Reverse width and height as the inverted orienvation should put them back again mBitmap = Bitmap.createBitmap(HEIGHT, WIDTH, Bitmap.Config.ARGB_8888); ResourceReleaser<Bitmap> releaser = SimpleBitmapReleaser.getInstance(); mCloseableStaticBitmap = new CloseableStaticBitmap( mBitmap, releaser, ImmutableQualityInfo.FULL_QUALITY, 0, ExifInterface.ORIENTATION_TRANSPOSE); assertThat(mCloseableStaticBitmap.getWidth()).isEqualTo(WIDTH); assertThat(mCloseableStaticBitmap.getHeight()).isEqualTo(HEIGHT); }
/** * 获取图片旋转角度 * * @param filePath 文件路径 * @return 旋转角度 */ public static int getRotateDegree(final 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; }
/** * Reads all the EXIF data from the input file. */ public void readExifData() { this.aperture = inFile.getAttribute(ExifInterface.TAG_APERTURE); this.datetime = inFile.getAttribute(ExifInterface.TAG_DATETIME); this.exposureTime = inFile.getAttribute(ExifInterface.TAG_EXPOSURE_TIME); this.flash = inFile.getAttribute(ExifInterface.TAG_FLASH); this.focalLength = inFile.getAttribute(ExifInterface.TAG_FOCAL_LENGTH); this.gpsAltitude = inFile.getAttribute(ExifInterface.TAG_GPS_ALTITUDE); this.gpsAltitudeRef = inFile.getAttribute(ExifInterface.TAG_GPS_ALTITUDE_REF); this.gpsDateStamp = inFile.getAttribute(ExifInterface.TAG_GPS_DATESTAMP); this.gpsLatitude = inFile.getAttribute(ExifInterface.TAG_GPS_LATITUDE); this.gpsLatitudeRef = inFile.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF); this.gpsLongitude = inFile.getAttribute(ExifInterface.TAG_GPS_LONGITUDE); this.gpsLongitudeRef = inFile.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF); this.gpsProcessingMethod = inFile.getAttribute(ExifInterface.TAG_GPS_PROCESSING_METHOD); this.gpsTimestamp = inFile.getAttribute(ExifInterface.TAG_GPS_TIMESTAMP); this.iso = inFile.getAttribute(ExifInterface.TAG_ISO); this.make = inFile.getAttribute(ExifInterface.TAG_MAKE); this.model = inFile.getAttribute(ExifInterface.TAG_MODEL); this.orientation = inFile.getAttribute(ExifInterface.TAG_ORIENTATION); this.whiteBalance = inFile.getAttribute(ExifInterface.TAG_WHITE_BALANCE); }
@Test public void testDoesNotResizeIfJpegButResizingDisabled() throws Exception { whenResizingDisabled(); final int preferredWidth = 300; final int preferredHeight = 600; whenRequestWidthAndHeight(preferredWidth, preferredHeight); whenRequestSpecificRotation(RotationOptions.NO_ROTATION); provideIntermediateResult( DefaultImageFormats.JPEG, preferredWidth * 2, preferredHeight * 2, 0, ExifInterface.ORIENTATION_NORMAL); verifyIntermediateResultPassedThroughUnchanged(); provideFinalResult( DefaultImageFormats.JPEG, preferredWidth * 2, preferredHeight * 2, 0, ExifInterface.ORIENTATION_NORMAL); verifyFinalResultPassedThroughUnchanged(); verifyZeroJpegTranscoderInteractions(); }
/** * 读取图片属性:图片被旋转的角度 * * @param path 图片绝对路径 * @return 旋转的角度 */ public static int getImageDegree(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; }
/** * 读取图片属性:旋转的角度 * * @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) { Logger.getLogger(PhotoHelper.class).e(e.getMessage()); } return degree; }
private static int getRotationFromCamera(Context context, Uri imageFile) { int rotate = 0; try { context.getContentResolver().notifyChange(imageFile, null); ExifInterface exif = new ExifInterface(imageFile.getPath()); 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; }
public static void savaPicExif(Context context, String fileName) { try { ExifInterface exifInterface = new ExifInterface(fileName); exifInterface.setAttribute(ExifInterface.TAG_DATETIME, System.currentTimeMillis() + ""); // if (CommonUtil.checkNetState(context) && BaseActivity.location != null && BaseActivity.location.getLatitude() != 0 && BaseActivity.location.getLongitude() != 0) { // exifInterface.setAttribute(ExifInterface.TAG_GPS_LATITUDE, BaseActivity.location.getLatitude() + ""); // exifInterface.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, BaseActivity.location.getLongitude() + ""); // } exifInterface.saveAttributes(); } catch (IOException e) { e.printStackTrace(); } }
private int exifToDegrees(int exifOrientation) { if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90) { return 90; } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180) { return 180; } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270) { return 270; } else { return 0; } }
public int getOrientation() { int o = Integer.parseInt(this.orientation); if (o == ExifInterface.ORIENTATION_NORMAL) { return 0; } else if (o == ExifInterface.ORIENTATION_ROTATE_90) { return 90; } else if (o == ExifInterface.ORIENTATION_ROTATE_180) { return 180; } else if (o == ExifInterface.ORIENTATION_ROTATE_270) { return 270; } else { return 0; } }
public void setOrientation() throws IOException { if (TextUtils.isEmpty(getAbsoluteImagePath())) { return; } BitmapFactory.Options bmOptions = new BitmapFactory.Options(); Bitmap bitmap = BitmapFactory.decodeFile(getAbsoluteImagePath(), bmOptions); ExifInterface ei = new ExifInterface(getAbsoluteImagePath()); int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_90: writeFile(rotateImage(bitmap, 90)); break; case ExifInterface.ORIENTATION_ROTATE_180: writeFile(rotateImage(bitmap, 180)); break; case ExifInterface.ORIENTATION_ROTATE_270: writeFile(rotateImage(bitmap, 270)); break; case ExifInterface.ORIENTATION_NORMAL: default: break; } }