Utility class for modifying metadata on JPEG files. Call #save() to persist changes to disc.
| 45 | |
| 46 | /** |
| 47 | * Utility class for modifying metadata on JPEG files. |
| 48 | * |
| 49 | * <p>Call {@link #save()} to persist changes to disc. |
| 50 | */ |
| 51 | public final class Exif { |
| 52 | |
| 53 | /** Timestamp value indicating a timestamp value that is either not set or not valid */ |
| 54 | public static final long INVALID_TIMESTAMP = -1; |
| 55 | // Forked from ExifInterface.TAG_THUMBNAIL_ORIENTATION. The value is library-internal so we |
| 56 | // can't depend on it directly. |
| 57 | public static final String TAG_THUMBNAIL_ORIENTATION = "ThumbnailOrientation"; |
| 58 | |
| 59 | private static final String TAG = Exif.class.getSimpleName(); |
| 60 | |
| 61 | private static final ThreadLocal<SimpleDateFormat> DATE_FORMAT = |
| 62 | new ThreadLocal<SimpleDateFormat>() { |
| 63 | @Override |
| 64 | public SimpleDateFormat initialValue() { |
| 65 | return new SimpleDateFormat("yyyy:MM:dd", Locale.US); |
| 66 | } |
| 67 | }; |
| 68 | private static final ThreadLocal<SimpleDateFormat> TIME_FORMAT = |
| 69 | new ThreadLocal<SimpleDateFormat>() { |
| 70 | @Override |
| 71 | public SimpleDateFormat initialValue() { |
| 72 | return new SimpleDateFormat("HH:mm:ss", Locale.US); |
| 73 | } |
| 74 | }; |
| 75 | private static final ThreadLocal<SimpleDateFormat> DATETIME_FORMAT = |
| 76 | new ThreadLocal<SimpleDateFormat>() { |
| 77 | @Override |
| 78 | public SimpleDateFormat initialValue() { |
| 79 | return new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", Locale.US); |
| 80 | } |
| 81 | }; |
| 82 | |
| 83 | private static final String KILOMETERS_PER_HOUR = "K"; |
| 84 | private static final String MILES_PER_HOUR = "M"; |
| 85 | private static final String KNOTS = "N"; |
| 86 | |
| 87 | /** All public tags in {@link ExifInterface}. */ |
| 88 | private static final List<String> ALL_EXIF_TAGS = getAllExifTags(); |
| 89 | // Exif tags that should not be copied to the cropped image. |
| 90 | private static final List<String> DO_NOT_COPY_EXIF_TAGS = Arrays.asList( |
| 91 | // Dimension-related tags, which might change after cropping. |
| 92 | ExifInterface.TAG_IMAGE_WIDTH, |
| 93 | ExifInterface.TAG_IMAGE_LENGTH, |
| 94 | ExifInterface.TAG_PIXEL_X_DIMENSION, |
| 95 | ExifInterface.TAG_PIXEL_Y_DIMENSION, |
| 96 | // Thumbnail-related tags. Currently we do not create thumbnail for cropped images. |
| 97 | ExifInterface.TAG_COMPRESSION, // Our primary image is always Jpeg. |
| 98 | ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT, |
| 99 | ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT_LENGTH, |
| 100 | ExifInterface.TAG_THUMBNAIL_IMAGE_LENGTH, |
| 101 | ExifInterface.TAG_THUMBNAIL_IMAGE_WIDTH, |
| 102 | TAG_THUMBNAIL_ORIENTATION); |
| 103 | |
| 104 | private final ExifInterface mExifInterface; |
nothing calls this directly
no test coverage detected