android / android/camera-samples
When use the method setTargetResolution, the metadata would be lost.
- Lingua principale
- Kotlin
- Stelle
- 5.5k
- Fork
- 2.4k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Use the code below to query metadata.
```
val model = ExifInterface(savedUri.toFile()).getAttribute(ExifInterface.TAG_MODEL)
Log.d(TAG, "Photo capture succeeded: model ==> $model")
```
Here is patch.
The target branch hash is : `852767fd` 2021/5/27 at 21:32
```
Index: CameraXBasic/app/src/main/AndroidManifest.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- CameraXBasic/app/src/main/AndroidManifest.xml (revision 852767fddd25b0f33e117d811bd5cdb6694b8904)
+++ CameraXBasic/app/src/main/AndroidManifest.xml (date 1624348335530)
@@ -41,7 +41,7 @@
android:clearTaskOnLaunch="true"
android:theme="@style/AppTheme"
android:icon="@mipmap/ic_launcher"
- android:screenOrientation="fullUser"
+ android:screenOrientation="portrait"
android:rotationAnimation="seamless"
android:resizeableActivity="true"
android:configChanges="orientation|screenLayout|screenSize|smallestScreenSize"
Index: CameraXBasic/app/src/main/res/layout/fragment_camera.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- CameraXBasic/app/src/main/res/layout/fragment_camera.xml (revision 852767fddd25b0f33e117d811bd5cdb6694b8904)
+++ CameraXBasic/app/src/main/res/layout/fragment_camera.xml (date 1624354469810)
@@ -14,8 +14,8 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintDimensionRatio="W, 3:4"
+ android:layout_height="0dp" />
\ No newline at end of file
Index: CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/CameraFragment.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/CameraFragment.kt (revision 852767fddd25b0f33e117d811bd5cdb6694b8904)
+++ CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/CameraFragment.kt (date 1624355800525)
@@ -30,6 +30,7 @@
import android.os.Build
import android.os.Bundle
import android.util.Log
+import android.util.Size
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.View
@@ -52,6 +53,7 @@
import androidx.core.content.ContextCompat
import androidx.core.net.toFile
import androidx.core.view.setPadding
+import androidx.exifinterface.media.ExifInterface
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.localbroadcastmanager.content.LocalBroadcastManager
@@ -290,7 +292,7 @@
// Preview
preview = Preview.Builder()
// We request aspect ratio but no resolution
- .setTargetAspectRatio(screenAspectRatio)
+ .setTargetResolution(Size(3648, 2736))
// Set initial target rotation
.setTargetRotation(rotation)
.build()
@@ -300,7 +302,7 @@
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
// We request aspect ratio but no resolution to match preview config, but letting
// CameraX optimize for whatever specific resolution best fits our use cases
- .setTargetAspectRatio(screenAspectRatio)
+ .setTargetResolution(Size(3648, 2736))
// Set initial target rotation, we will have to call this again if rotation changes
// during the lifecycle of this use case
.setTargetRotation(rotation)
@@ -309,7 +311,7 @@
// ImageAnalysis
imageAnalyzer = ImageAnalysis.Builder()
// We request aspect ratio but no resolution
- .setTargetAspectRatio(screenAspectRatio)
+ .setTargetResolution(Size(3648, 2736))
// Set initial target rotation, we will have to call this again if rotation changes
// during the lifecycle of this use case
.setTargetRotation(rotation)
@@ -411,6 +413,9 @@
val savedUri = output.savedUri ?: Uri.fromFile(photoFile)
Log.d(TAG, "Photo capture succeeded: $savedUri")
+ val model = ExifInterface(savedUri.toFile()).getAttribute(ExifInterface.TAG_MODEL)
+ Log.d(TAG, "Photo capture succeeded: model ==> $model")
+
// We can only change the foreground Drawable using API level 23+ API
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// Update the gallery thumbnail with latest picture taken
```
I found that the metadata lost after `androidx.camera.core.internal.utils.ImageUtil#cropByteArray` called.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/CameraFragment.kt e riproduci la ricerca dei metadati segnalata dopo aver usato setTargetResolution. Segui il percorso segnalato attraverso androidx.camera.core.internal.utils.ImageUtil#cropByteArray e confronta i metadati dell’immagine salvata con il risultato di ExifInterface TAG_MODEL. Il lavoro è completato quando sono stati identificati i motivi per cui i metadati vengono persi ed è stato confermato che i metadati acquisiti vengono preservati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- android, kotlin
- Ambito
- mobile
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100