0

I was looking at many problems but still im confused.

I want to add the exif block in my file where and how can i do this .

I am new to Android Programming language. I have a camera code i generate a photo file with a unique name and it smoothly saves photo in my own created directory on sdcard. However, i am unable to judge how to insert the EXIFINTERFACE to my photo file. I want to assign gps coordinates, I have a location listener class working and i will get Lattitude Longitude Strings from there for setting attributes of Exif block

ExifInterface exif = new ExifInterface(string filepath);

this command requires string of filepath and i am generating file in two methods.

 public static File getPhotoDirectory()  {
    File outputDir = null;
    String externalStorageState = Environment.getExternalStorageState();
    if (externalStorageState.equals(Environment.MEDIA_MOUNTED)) {
        File pictureDir =
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
        outputDir = new File(pictureDir, "HasanDirectory");
        if(!outputDir.exists())  {
            if(!outputDir.mkdirs()) {
                String message = "Failed to create directory:" + outputDir.getAbsolutePath();
                Log.e(LOG_TAG, message);
                outputDir = null;
            }
        }
    }


    return outputDir;
}

  public static File generateTimeStampPhotoFile() {
    File photoFile = null;
    File outputDir = getPhotoDirectory();

    if (outputDir != null) {
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        //if (type == MEDIA_TYPE_IMAGE){
        picCount++; // "HA" provides a unique number to each pic
        String photoFileName =  "IMG_" + timeStamp + "_" + picCount + ".jpg";

        photoFile = new File(outputDir, photoFileName);
        }

    return photoFile;
}

Guide me how can i add the exif block?

OR please, if you are reading this far? what are other methods to assign GPS coordinates to a picture? does setParameters function of Camera class in android works?

Pythonoid
  • 65
  • 10
  • Checkout this SO post: http://stackoverflow.com/questions/11644873/android-write-exif-gps-latitude-and-longitude-onto-jpeg-failed – alpinescrambler Nov 06 '14 at 07:51
  • i am making a new photofile everytime. a name with timestamp, and piccount, i want to assign the coordinates to each picture. – Pythonoid Nov 06 '14 at 08:11
  • so what to write in "new ExifInterfance( how to pull path of each photo here)" – Pythonoid Nov 06 '14 at 08:12
  • your function generateTimeStampPhotoFile returns a File object. So I guess after you save your photofile, immediately call the exif routines... exif = new ExifInterface(YourPhotoFileVariable.getCanonicalPath()); – alpinescrambler Nov 06 '14 at 08:16
  • as you mentioned, my file is saved, when i call generateTimeStampPhotoFile() when capturing in on onPictureJpeg(byte[] bytes, Camera camera).. – Pythonoid Nov 06 '14 at 09:01
  • so shud i use exif in that place with the outStream.write and outstream.flush etc. .? – Pythonoid Nov 06 '14 at 09:01

0 Answers0