Assigned
Status Update
Comments
mi...@google.com <mi...@google.com>
an...@bees360.com <an...@bees360.com> #2
attach file
ib...@google.com <ib...@google.com> #3
Please can you check whether the issue still reproduces with exifinterface:1.4.0-alpha01
? It contains many fixes on top of 1.3.7.
Thanks!
an...@bees360.com <an...@bees360.com> #4
This problem persisted even after I used 1.4.0-alpha01. In the end, I suspected that there was something wrong with the image file, but I couldn't prove it. The only way to get the width and height is as follows:
val exifInterface = androidx.exifinterface.media.ExifInterface(file)
// Image Size.
var tagImageLength = exifInterface.getAttribute(ExifInterface.TAG_IMAGE_LENGTH)
var tagImageWidth = exifInterface.getAttribute(ExifInterface.TAG_IMAGE_WIDTH)
if ("0" == tagImageWidth || "0" == tagImageLength) {
tagImageWidth = exifInterface.getAttribute(ExifInterface.TAG_PIXEL_X_DIMENSION)
tagImageLength = exifInterface.getAttribute(ExifInterface.TAG_PIXEL_Y_DIMENSION)
Timber.e("Get image wh is (0,0), try get wh from TAG_PIXEL_X_DIMENSION & TAG_PIXEL_Y_DIMENSION, result is ($tagImageWidth,$tagImageLength)")
}
val exifInterface = androidx.exifinterface.media.ExifInterface(file)
// Image Size.
var tagImageLength = exifInterface.getAttribute(ExifInterface.TAG_IMAGE_LENGTH)
var tagImageWidth = exifInterface.getAttribute(ExifInterface.TAG_IMAGE_WIDTH)
if ("0" == tagImageWidth || "0" == tagImageLength) {
tagImageWidth = exifInterface.getAttribute(ExifInterface.TAG_PIXEL_X_DIMENSION)
tagImageLength = exifInterface.getAttribute(ExifInterface.TAG_PIXEL_Y_DIMENSION)
Timber.e("Get image wh is (0,0), try get wh from TAG_PIXEL_X_DIMENSION & TAG_PIXEL_Y_DIMENSION, result is ($tagImageWidth,$tagImageLength)")
}
Description
2. Use the same code to get other images with normal width and height.
expected: width is 4000, length is 3000
code:
```kotlin
val length = ExifInterface(File(context.filesDir, "b2a9e20e08e53226aef9acbcdd9a1d21.jpg").absolutePath).getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, -1)
println("lenght: $length")
// length: 0
```
dependencies:
implementation "androidx.exifinterface:exifinterface:1.3.7"