glide
glide copied to clipboard
EXIF HEIC image rotation is ignored for URLs and files
Glide Version: 4.13.2
Integration libraries: None
Device/Android Version: Emulator (Pixel 2 - API 30 - Android 11) and Huawei P30 lite
Issue details / Repro steps / Use case background: I'm trying to load images from the web, delivered by an API. Those images sometimes contain EXIF data with rotation information and Glide should automatically rotate those as requested. But for example in the case of the attached image (see below) the rotation isn't correctly applied.
- If a URL (as string) or a file is used to request the image via Glide, it doesn't get rotated. 🛑
- If I use the path of the file the rotation values are honored. ✅
Glide load line / GlideModule
(if any) / list Adapter code (if any):
I just created a default Android example app, added three image views and loaded the same image in the three mentioned ways.
In onViewCreated() in FirstFragment
val url = "https://url-hosting-some-images.com/your-image.HEIC"
val result = runBlocking(Dispatchers.IO) {
val file = Glide.with(this@FirstFragment).downloadOnly().load(url).submit()
file.get()
}
firstImage(url)
secondImage(result)
thirdImage(result.absolutePath)
The actual methods in FirstFragment
// rotation is missing
private fun firstImage(url: String) {
Glide
.with(this)
.load(url)
.into(binding.imageFirst);
}
// rotation is missing
private fun secondImage(file: File) {
Glide
.with(this)
.load(file)
.into(binding.imageSecond);
}
// rotation is correctly displayed
private fun thirdImage(path: String) {
Glide
.with(this)
.load(path)
.into(binding.imageThird);
}
Layout XML:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FirstFragment">
<TextView
android:id="@+id/textview_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_first_fragment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textview_first"
tools:src="@drawable/ic_launcher_foreground"
android:id="@+id/image_first"
android:contentDescription="first"
android:layout_width="0dp"
android:layout_height="150dp" />
<ImageView
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/image_first"
tools:src="@drawable/ic_launcher_foreground"
android:id="@+id/image_second"
android:contentDescription="second"
android:layout_width="0dp"
android:layout_height="150dp" />
<ImageView
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/image_second"
tools:src="@drawable/ic_launcher_foreground"
android:id="@+id/image_third"
android:contentDescription="third"
android:layout_width="0dp"
android:layout_height="150dp" />
<Button
android:id="@+id/button_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/next"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/image_third" />
</androidx.constraintlayout.widget.ConstraintLayout>
Stack trace / LogCat: No errors
Screenshot:
Example image: As GitHub doesn't support HEIC attachments I had to zip it. example_image.zip
I'm not able to reproduce this with the given image on an API 30 emulator. Using either a File or a filepath both work.
That's strange, I can give it another try next week to check if something changed.
Have you tried the URL case, as this was at least for me the most relevant one. The filePath
case was also for me the one that always worked. Only File
and url
(as String) weren't correctly displayed in my tests.
I just retested the issue and was able to reproduce the problem. Please have a look at https://github.com/Boehrsi/glide_heic_exif_bug this sample project demonstrates the issue.
Thanks for the sample app. This is a duplicate of #4778 and is fixed in 4.14.0