Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6171255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:10:51+00:00 2026-05-23T23:10:51+00:00

I am trying to re-size an image, that part completed. Then I’m trying to

  • 0

I am trying to re-size an image, that part completed.
Then I’m trying to copy exif tags to new file.
I use ExifInterface to read tags.
I know it’s an interface not an object.
But When I try to use it for really big sized image, I get NullPointerException.
I get this error not for all the images.

07-25 11:59:23.870: WARN/System.err(1362): java.lang.NullPointerException
07-25 11:59:23.870: WARN/System.err(1362):     at android.media.ExifInterface.saveAttributes(ExifInterface.java:202)

How do I solve it?

Code to copy exif information

try {
    // copy paste exif information from original file to new
    // file
    ExifInterface oldexif = new ExifInterface(filePath);
    ExifInterface newexif = new ExifInterface(file.getPath());

    int build = Build.VERSION.SDK_INT;

    // From API 11
    if (build >= 11) {
        newexif.setAttribute("FNumber",
                oldexif.getAttribute("FNumber"));
        newexif.setAttribute("ExposureTime",
                oldexif.getAttribute("ExposureTime"));
        newexif.setAttribute("ISOSpeedRatings",
                oldexif.getAttribute("ISOSpeedRatings"));
    }
    // From API 9
    if (build >= 9) {
        newexif.setAttribute("GPSAltitude",
                oldexif.getAttribute("GPSAltitude"));
        newexif.setAttribute("GPSAltitudeRef",
                oldexif.getAttribute("GPSAltitudeRef"));
    }
    // From API 8
    if (build >= 8) {
        newexif.setAttribute("FocalLength",
                oldexif.getAttribute("FocalLength"));
        newexif.setAttribute("GPSDateStamp",
                oldexif.getAttribute("GPSDateStamp"));
        newexif.setAttribute("GPSProcessingMethod",
                oldexif.getAttribute("GPSProcessingMethod"));
        newexif.setAttribute("GPSTimeStamp",
                oldexif.getAttribute("GPSTimeStamp"));
    }
    newexif.setAttribute("DateTime",
            oldexif.getAttribute("DateTime"));
    newexif.setAttribute("Flash", oldexif.getAttribute("Flash"));
    newexif.setAttribute("GPSLatitude",
            oldexif.getAttribute("GPSLatitude"));
    newexif.setAttribute("GPSLatitudeRef",
            oldexif.getAttribute("GPSLatitudeRef"));
    newexif.setAttribute("GPSLongitude",
            oldexif.getAttribute("GPSLongitude"));
    newexif.setAttribute("GPSLongitudeRef",
            oldexif.getAttribute("GPSLongitudeRef"));

    // You need to update this with your new height width
    newexif.setAttribute("ImageLength",
            oldexif.getAttribute("ImageLength"));
    newexif.setAttribute("ImageWidth",
            oldexif.getAttribute("ImageWidth"));

    newexif.setAttribute("Make", oldexif.getAttribute("Make"));
    newexif.setAttribute("Model", oldexif.getAttribute("Model"));
    newexif.setAttribute("Orientation",
            oldexif.getAttribute("Orientation"));
    newexif.setAttribute("WhiteBalance",
            oldexif.getAttribute("WhiteBalance"));

    newexif.saveAttributes();

    Toast.makeText(getApplicationContext(),
            "Image resized & saved successfully",
            Toast.LENGTH_SHORT).show();
} catch (Exception e) {
    e.printStackTrace();
}

Additional onFly information:

New file is created when I’m trying to read both the file:
enter image description here


Debug watch on oldexif
enter image description here


Debug watch on newexif
enter image description here


Testing image

http://vikaskanani.files.wordpress.com/2011/07/test.jpg


Using Android emulator for sdk 2.1

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:10:52+00:00Added an answer on May 23, 2026 at 11:10 pm

    You are passing a null value somewhere in the saveAttributes.

    Debugging NullPointerExceptions is very easy, providing you have the sourcecode.

    Below you can find the sourcecode for the ExifInterface for Android 2.1

    http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.1_r2/android/media/ExifInterface.java#ExifInterface

    line 202 contains this :

    sb.append(val.length() + " ");
    

    Only thing that can be null here is val. (one of the values you’re passing in the saveAttributes method).

    I would suggest double checking the values you’re passing onto that value, and watch out for null values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an svg image as a background. I'm trying to use CSS3's background-size:
I'm trying to re-size a image in HTML, it's got width 314px and height
I'm trying to get the image.size.h and image.size.w of the UIImage inside of an
I changed image of cursor. I am trying to change size of cursor image
I am trying to increase the size of the image by 20. So I
I'm trying to write a method to reduce the size of any image 50%
I'm trying to load about 600 small images into memory. Size of each image
Edit: To those who need to blit an image(i.e. copy a part of a
I'm trying to come up with my own star image that's slightly smaller and
I am trying to decide where to store images that are sent as part

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.