Bitmap realImage = BitmapFactory.decodeStream(stream); ExifInterface exif=new ExifInterface(getRealPathFromURI(imagePath)); Log.d("EXIF value", exif.getAttribute(ExifInterface.TAG_ORIENTATION)); if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("6")){ realImage=ImageUtil.rotate(realImage, 90); }else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("8")){ realImage=ImageUtil.rotate(realImage, 270); }else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("3")){ realImage=ImageUtil.rotate(realImage, 180); }
final ExifInterface exif = new ExifInterface(imageUri.getPath()); final int rotation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); final String datestamp = exif.getAttribute(ExifInterface.TAG_GPS_DATESTAMP); final String gpsLatitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE); final String gpsLatitudeRef = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF); ...
ExifInterface exif = new ExifInterface(SourceFileName); //Since API Level 5 String exifOrientation = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
ExifInterface exif = new ExifInterface("filepath"); exif.getAttribute(ExifInterface.TAG_ORIENTATION);
ExifInterface oldExif = new ExifInterface(oldImagePath); String exifOrientation = oldExif.getAttribute(ExifInterface.TAG_ORIENTATION); if (exifOrientation != null) { ExifInterface newExif = new ExifInterface(imagePath); newExif.setAttribute(ExifInterface.TAG_ORIENTATION, exifOrientation); newExif.saveAttributes(); }
/** * Load the exif tags into the passed Bundle * * @param filepath * @param out * @return true if exif tags are loaded correctly */ public static boolean loadAttributes( final String filepath, Bundle out ) { ExifInterface e; try { e = new ExifInterface( filepath ); } catch ( IOException e1 ) { e1.printStackTrace(); return false; } for ( String tag : EXIF_TAGS ) { out.putString( tag, e.getAttribute( tag ) ); } return true; }
BitmapFactory.Options bounds = new BitmapFactory.Options(); bounds.inJustDecodeBounds = true; BitmapFactory.decodeFile(file, bounds); BitmapFactory.Options opts = new BitmapFactory.Options(); Bitmap bm = BitmapFactory.decodeFile(file, opts); ExifInterface exif = new ExifInterface(file); String orientString = exif.getAttribute(ExifInterface.TAG_ORIENTATION); int orientation = orientString != null ? Integer.parseInt(orientString) : ExifInterface.ORIENTATION_NORMAL; int rotationAngle = 0; if (orientation == ExifInterface.ORIENTATION_ROTATE_90) rotationAngle = 90; if (orientation == ExifInterface.ORIENTATION_ROTATE_180) rotationAngle = 180; if (orientation == ExifInterface.ORIENTATION_ROTATE_270) rotationAngle = 270; Matrix matrix = new Matrix(); matrix.setRotate(rotationAngle, (float) bm.getWidth() / 2, (float) bm.getHeight() / 2); Bitmap rotatedBitmap = Bitmap.createBitmap(bm, 0, 0, bounds.outWidth, bounds.outHeight, matrix, true);
Log.d("EXIF value", exif.getAttribute(ExifInterface.TAG_ORIENTATION)); if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("6")){ realImage= rotate(realImage, 90); } else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("8")){ realImage= rotate(realImage, 270); } else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("3")){ realImage= rotate(realImage, 180); } else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("0")){ realImage= rotate(realImage, 90);
public static boolean copyExifRotation(File sourceFile, File destFile) { if (sourceFile == null || destFile == null) return false; try { ExifInterface exifSource = new ExifInterface(sourceFile.getAbsolutePath()); ExifInterface exifDest = new ExifInterface(destFile.getAbsolutePath()); exifDest.setAttribute(ExifInterface.TAG_ORIENTATION, exifSource.getAttribute(ExifInterface.TAG_ORIENTATION)); exifDest.saveAttributes(); return true; } catch (IOException e) { Log.e("Error copying Exif data", e); return false; } }
String value; for (String attribute : attributes) { value = originalExif.getAttribute(attribute); if (!TextUtils.isEmpty(value)) { newExif.setAttribute(attribute, value);
String value; for (String tag : tags) { value = sourceExif.getAttribute(tag); if (!TextUtils.isEmpty(value)) { saveExif.setAttribute(tag, value);
String value; for (String attribute : attributes) { value = originalExif.getAttribute(attribute); if (!TextUtils.isEmpty(value)) { newExif.setAttribute(attribute, value);
try { ExifInterface ef = new ExifInterface(flNm); sLat = ef.getAttribute(ExifInterface.TAG_GPS_LATITUDE); sLon = ef.getAttribute(ExifInterface.TAG_GPS_LONGITUDE); sLatR = ef.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF); sLonR = ef.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF); } catch (IOException e) {return null;}
for (int i = 0; i < attributes.length; i++) String value = oldExif.getAttribute(attributes[i]); if (value != null) newExif.setAttribute(attributes[i], value);
ExifInterface exif = new ExifInterface(filepath); exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE); exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF); exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE); exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF);
public static double getExifDouble(ExifInterface ei, String tag, double defaultValue) { String value = ei.getAttribute(tag); if(value == null) return defaultValue; try { return Double.parseDouble(value); } catch(NumberFormatException e) { return defaultValue; } }
ExifInterface intf = null; try { intf = new ExifInterface(path); } catch(IOException e) { e.printStackTrace(); } if(intf == null) { /* File doesn't exist or isn't an image */ } String dateString = intf.getAttribute(ExifInterface.TAG_DATETIME); /* Do your date/time stuff here */
try { ExifInterface ei = new ExifInterface("file path"); String make = ei.getAttribute(ExifInterface.TAG_MAKE); String model = ei.getAttribute(ExifInterface.TAG_MODEL); } catch (IOException e) { e.printStackTrace(); }
private static int getExifOrientation(String src) throws IOException { int orientation = 1; ExifInterface exif = new ExifInterface(src); String orientationString=exif.getAttribute(ExifInterface.TAG_ORIENTATION); try { orientation = Integer.parseInt(orientationString); } catch(NumberFormatException e){} return orientation; }
public static boolean copyExifRotation(File sourceFile, File destFile) { if (sourceFile == null || destFile == null) return false; try { ExifInterface exifSource = new ExifInterface(sourceFile.getAbsolutePath()); ExifInterface exifDest = new ExifInterface(destFile.getAbsolutePath()); exifDest.setAttribute(ExifInterface.TAG_ORIENTATION, exifSource.getAttribute(ExifInterface.TAG_ORIENTATION)); exifDest.saveAttributes(); return true; } catch (IOException e) { return false; } }