當前位置: 首頁>>代碼示例>>Java>>正文


Java ExifInterface.saveAttributes方法代碼示例

本文整理匯總了Java中android.media.ExifInterface.saveAttributes方法的典型用法代碼示例。如果您正苦於以下問題:Java ExifInterface.saveAttributes方法的具體用法?Java ExifInterface.saveAttributes怎麽用?Java ExifInterface.saveAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.media.ExifInterface的用法示例。


在下文中一共展示了ExifInterface.saveAttributes方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: copyExifRotation

import android.media.ExifInterface; //導入方法依賴的package包/類
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;
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:CropUtil.java

示例4: copyExifRotation

import android.media.ExifInterface; //導入方法依賴的package包/類
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;
    }
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:14,代碼來源:CropUtil.java

示例5: copyExifRotation

import android.media.ExifInterface; //導入方法依賴的package包/類
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", String.valueOf(e));
        return false;
    }
}
 
開發者ID:liuyanggithub,項目名稱:SuperSelector,代碼行數:14,代碼來源:CropUtil.java

示例6: setPictureDegreeZero

import android.media.ExifInterface; //導入方法依賴的package包/類
/**
 * 設置圖片旋轉角度
 *
 * @param path 路徑
 * @param rotate 角度
 */
public static void setPictureDegreeZero(String path, int rotate) {
    try {
        ExifInterface exifInterface = new ExifInterface(path);
        //修正圖片的旋轉角度,設置其不旋轉。這裏也可以設置其旋轉的角度,可以傳值過去,
        //例如旋轉90度,傳值ExifInterface.ORIENTATION_ROTATE_90,需要將這個值轉換為String類型的
        exifInterface.setAttribute(ExifInterface.TAG_ORIENTATION, String
                .valueOf(rotate));
        exifInterface.saveAttributes();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:imliujun,項目名稱:LJFramework,代碼行數:19,代碼來源:BitmapUtils.java

示例7: savaPicExif

import android.media.ExifInterface; //導入方法依賴的package包/類
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();
        }
    }
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:14,代碼來源:FileUtil.java

示例8: setImageOrientation

import android.media.ExifInterface; //導入方法依賴的package包/類
public static void setImageOrientation(File file, int orientation) {
    if (file != null) {
        try {
            ExifInterface exifInterface = new ExifInterface(file.getPath());
            String orientationValue = String.valueOf(getOrientationExifValue(orientation));
            exifInterface.setAttribute(ExifInterface.TAG_ORIENTATION, orientationValue);
            exifInterface.saveAttributes();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:akexorcist,項目名稱:CameraSample,代碼行數:13,代碼來源:CameraV1Util.java

示例9: setExifOrientation

import android.media.ExifInterface; //導入方法依賴的package包/類
public static boolean setExifOrientation(String path, int orientation) {
    try {
        ExifInterface exif = new ExifInterface(path);
        exif.setAttribute(ExifInterface.TAG_ORIENTATION, getExifOrientation(orientation));
        exif.saveAttributes();
    } catch (IOException e) {
        e.printStackTrace();
        return false;

    }

    return true;
}
 
開發者ID:rosberry,項目名稱:media-picker-android,代碼行數:14,代碼來源:ExifUtils.java

示例10: writeDataToFile

import android.media.ExifInterface; //導入方法依賴的package包/類
public void writeDataToFile(File file, ReadableMap options, int jpegQualityPercent) throws IOException {
    FileOutputStream fos = new FileOutputStream(file);
    fos.write(toJpeg(currentRepresentation, jpegQualityPercent));
    fos.close();

    try {
        ExifInterface exif = new ExifInterface(file.getAbsolutePath());

        // copy original exif data to the output exif...
        // unfortunately, this Android ExifInterface class doesn't understand all the tags so we lose some
        for (Directory directory : originalImageMetaData().getDirectories()) {
            for (Tag tag : directory.getTags()) {
                int tagType = tag.getTagType();
                Object object = directory.getObject(tagType);
                exif.setAttribute(tag.getTagName(), object.toString());
            }
        }

        writeLocationExifData(options, exif);

        if(hasBeenReoriented)
            rewriteOrientation(exif);

        exif.saveAttributes();
    } catch (ImageProcessingException | IOException e) {
        Log.e(TAG, "failed to save exif data", e);
    }
}
 
開發者ID:jonathan68,項目名稱:react-native-camera,代碼行數:29,代碼來源:MutableImage.java

示例11: copyExif

import android.media.ExifInterface; //導入方法依賴的package包/類
public static void copyExif(ExifInterface originalExif, int width, int height, String imageOutputPath) {
    String[] attributes = new String[]{
            ExifInterface.TAG_APERTURE,
            ExifInterface.TAG_DATETIME,
            ExifInterface.TAG_DATETIME_DIGITIZED,
            ExifInterface.TAG_EXPOSURE_TIME,
            ExifInterface.TAG_FLASH,
            ExifInterface.TAG_FOCAL_LENGTH,
            ExifInterface.TAG_GPS_ALTITUDE,
            ExifInterface.TAG_GPS_ALTITUDE_REF,
            ExifInterface.TAG_GPS_DATESTAMP,
            ExifInterface.TAG_GPS_LATITUDE,
            ExifInterface.TAG_GPS_LATITUDE_REF,
            ExifInterface.TAG_GPS_LONGITUDE,
            ExifInterface.TAG_GPS_LONGITUDE_REF,
            ExifInterface.TAG_GPS_PROCESSING_METHOD,
            ExifInterface.TAG_GPS_TIMESTAMP,
            ExifInterface.TAG_ISO,
            ExifInterface.TAG_MAKE,
            ExifInterface.TAG_MODEL,
            ExifInterface.TAG_SUBSEC_TIME,
            ExifInterface.TAG_SUBSEC_TIME_DIG,
            ExifInterface.TAG_SUBSEC_TIME_ORIG,
            ExifInterface.TAG_WHITE_BALANCE
    };

    try {
        ExifInterface newExif = new ExifInterface(imageOutputPath);
        String value;
        for (String attribute : attributes) {
            value = originalExif.getAttribute(attribute);
            if (!TextUtils.isEmpty(value)) {
                newExif.setAttribute(attribute, value);
            }
        }
        newExif.setAttribute(ExifInterface.TAG_IMAGE_WIDTH, String.valueOf(width));
        newExif.setAttribute(ExifInterface.TAG_IMAGE_LENGTH, String.valueOf(height));
        newExif.setAttribute(ExifInterface.TAG_ORIENTATION, "0");

        newExif.saveAttributes();

    } catch (IOException e) {
        Log.d(TAG, e.getMessage());
    }
}
 
開發者ID:Alcatraz323,項目名稱:MaterialOCR,代碼行數:46,代碼來源:ImageHeaderParser.java

示例12: saveImageWithQuality

import android.media.ExifInterface; //導入方法依賴的package包/類
private File saveImageWithQuality(Bitmap image, int quality, String rotation)
{
    File savedImage = getNewImageLocation();

    try
    {
        if (savedImage == null)
        {
            throw new IOException("Could not create location for image file");
        }

        boolean created = savedImage.createNewFile();
        if (created == false)
        {
            throw new IOException("Could not create empty image file");
        }

        FileOutputStream fOut = new FileOutputStream(savedImage);
        boolean fileWritten = image.compress(Bitmap.CompressFormat.JPEG, quality, fOut);
        fOut.flush();
        fOut.close();

        if (fileWritten == false)
        {
            throw new IOException("Could not down compress file");
        }

        ExifInterface exifData = new ExifInterface(savedImage.getAbsolutePath());
        exifData.setAttribute(ExifInterface.TAG_ORIENTATION, rotation);
        exifData.saveAttributes();

        Log.i(TAG, "Image file " + savedImage.getAbsolutePath() + " saved at quality " + quality + " and rotation " + rotation);

        return savedImage;
    }
    catch(IOException e)
    {
        Log.e(TAG, "Failed to encode image", e);
        Toast.makeText(this, R.string.pictureCaptureError, Toast.LENGTH_LONG).show();

        if(savedImage != null)
        {
            boolean result = savedImage.delete();
            if(result == false)
            {
                Log.w(TAG, "Failed to delete image file: " + savedImage.getAbsolutePath());
            }
        }
    }

    return null;
}
 
開發者ID:brarcher,項目名稱:rental-calc,代碼行數:53,代碼來源:PropertyPicturesActivity.java

示例13: writeDataToFile

import android.media.ExifInterface; //導入方法依賴的package包/類
public void writeDataToFile(File file, ReadableMap options, int jpegQualityPercent) throws IOException {
    FileOutputStream fos = new FileOutputStream(file);
    fos.write(toJpeg(currentRepresentation, jpegQualityPercent));
    fos.close();

    try {
        ExifInterface exif = new ExifInterface(file.getAbsolutePath());

        // copy original exif data to the output exif...
        // unfortunately, this Android ExifInterface class doesn't understand all the tags so we lose some
        for (Directory directory : originalImageMetaData().getDirectories()) {
            for (Tag tag : directory.getTags()) {
                int tagType = tag.getTagType();
                Object object = directory.getObject(tagType);
                exif.setAttribute(tag.getTagName(), object.toString());
            }
        }

        writeLocationExifData(options, exif);

        if(hasBeenReoriented)
            rewriteOrientation(exif);

        exif.saveAttributes();
    } catch (ImageProcessingException  | IOException e) {
        Log.e(TAG, "failed to save exif data", e);
    }
}
 
開發者ID:entria,項目名稱:react-native-camera-face-detector,代碼行數:29,代碼來源:MutableImage.java


注:本文中的android.media.ExifInterface.saveAttributes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。