<p dir="auto"><strong>Glide Version</strong>: 4.13.2</p>

<p dir="auto"><strong>Integration libraries</strong>: None</p>

<p dir="auto"><strong>Device/Android Version</strong>: Emulator (Pixel 2 - API 30 - Android 11) and Huawei P30 lite</p>

<p dir="auto"><strong>Issue details / Repro steps / Use case background</strong>:<br>
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.</p>
<ul dir="auto">
<li>If a URL (as string) or a file is used to request the image via Glide, it doesn't get rotated.  <g-emoji class="g-emoji" alias="stop_sign" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f6d1.png">🛑</g-emoji></li>
<li>If I use the path of the file the rotation values are honored. <g-emoji class="g-emoji" alias="white_check_mark" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2705.png">✅</g-emoji></li>
</ul>

<p dir="auto"><strong>Glide load line / <code class="notranslate">GlideModule</code> (if any) / list Adapter code (if any)</strong>:<br>
I just created a default Android example app, added three image views and loaded the same image in the three mentioned ways.</p>
<p dir="auto">In onViewCreated() in FirstFragment</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="val url = &quot;https://url-hosting-some-images.com/your-image.HEIC&quot;
val result = runBlocking(Dispatchers.IO) {
    val file = Glide.with(this@FirstFragment).downloadOnly().load(url).submit()
    file.get()
}
firstImage(url)
secondImage(result)
thirdImage(result.absolutePath)"><pre class="notranslate"><span class="pl-smi">val</span> <span class="pl-s1">url</span> = <span class="pl-s">"https://url-hosting-some-images.com/your-image.HEIC"</span>
<span class="pl-smi">val</span> <span class="pl-s1">result</span> = <span class="pl-en">runBlocking</span>(<span class="pl-smi">Dispatchers</span>.<span class="pl-c1">IO</span>) {
    <span class="pl-smi">val</span> <span class="pl-s1">file</span> = <span class="pl-smi">Glide</span>.<span class="pl-en">with</span>(<span class="pl-smi">this</span><span class="pl-c1">@</span><span class="pl-s1">FirstFragment</span>).<span class="pl-en">downloadOnly</span>().<span class="pl-en">load</span>(<span class="pl-s1">url</span>).<span class="pl-en">submit</span>()
    <span class="pl-s1">file</span>.<span class="pl-en">get</span>()
}
<span class="pl-en">firstImage</span>(<span class="pl-s1">url</span>)
<span class="pl-en">secondImage</span>(<span class="pl-s1">result</span>)
<span class="pl-en">thirdImage</span>(<span class="pl-s1">result</span>.<span class="pl-s1">absolutePath</span>)</pre></div>
<p dir="auto">The actual methods in FirstFragment</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// 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);
}"><pre class="notranslate"><span class="pl-c">// rotation is missing</span>
<span class="pl-k">private</span> <span class="pl-smi">fun</span> <span class="pl-s1">firstImage</span>(<span class="pl-smi">url</span>: <span class="pl-s1">String</span>) {
    <span class="pl-smi">Glide</span>
        .<span class="pl-en">with</span>(<span class="pl-smi">this</span>)
        .<span class="pl-en">load</span>(<span class="pl-s1">url</span>)
        .<span class="pl-en">into</span>(<span class="pl-s1">binding</span>.<span class="pl-s1">imageFirst</span>);
}

<span class="pl-c">// rotation is missing</span>
<span class="pl-k">private</span> <span class="pl-smi">fun</span> <span class="pl-s1">secondImage</span>(<span class="pl-smi">file</span>: <span class="pl-s1">File</span>) {
    <span class="pl-smi">Glide</span>
        .<span class="pl-en">with</span>(<span class="pl-smi">this</span>)
        .<span class="pl-en">load</span>(<span class="pl-s1">file</span>)
        .<span class="pl-en">into</span>(<span class="pl-s1">binding</span>.<span class="pl-s1">imageSecond</span>);
}

<span class="pl-c">// rotation is correctly displayed</span>
<span class="pl-k">private</span> <span class="pl-smi">fun</span> <span class="pl-s1">thirdImage</span>(<span class="pl-smi">path</span>: <span class="pl-s1">String</span>) {
    <span class="pl-smi">Glide</span>
        .<span class="pl-en">with</span>(<span class="pl-smi">this</span>)
        .<span class="pl-en">load</span>(<span class="pl-s1">path</span>)
        .<span class="pl-en">into</span>(<span class="pl-s1">binding</span>.<span class="pl-s1">imageThird</span>);
}</pre></div>

<p dir="auto"><strong>Layout XML</strong>:</p>
<div class="highlight highlight-text-xml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    tools:context=&quot;.FirstFragment&quot;&gt;

    &lt;TextView
        android:id=&quot;@+id/textview_first&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/hello_first_fragment&quot;
        app:layout_constraintEnd_toEndOf=&quot;parent&quot;
        app:layout_constraintStart_toStartOf=&quot;parent&quot;
        app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;

    &lt;ImageView
        app:layout_constraintEnd_toEndOf=&quot;parent&quot;
        app:layout_constraintStart_toStartOf=&quot;parent&quot;
        app:layout_constraintTop_toBottomOf=&quot;@id/textview_first&quot;
        tools:src=&quot;@drawable/ic_launcher_foreground&quot;
        android:id=&quot;@+id/image_first&quot;
        android:contentDescription=&quot;first&quot;
        android:layout_width=&quot;0dp&quot;
        android:layout_height=&quot;150dp&quot; /&gt;

    &lt;ImageView
        app:layout_constraintEnd_toEndOf=&quot;parent&quot;
        app:layout_constraintStart_toStartOf=&quot;parent&quot;
        app:layout_constraintTop_toBottomOf=&quot;@id/image_first&quot;
        tools:src=&quot;@drawable/ic_launcher_foreground&quot;
        android:id=&quot;@+id/image_second&quot;
        android:contentDescription=&quot;second&quot;
        android:layout_width=&quot;0dp&quot;
        android:layout_height=&quot;150dp&quot; /&gt;

    &lt;ImageView
        app:layout_constraintEnd_toEndOf=&quot;parent&quot;
        app:layout_constraintStart_toStartOf=&quot;parent&quot;
        app:layout_constraintTop_toBottomOf=&quot;@id/image_second&quot;
        tools:src=&quot;@drawable/ic_launcher_foreground&quot;
        android:id=&quot;@+id/image_third&quot;
        android:contentDescription=&quot;third&quot;
        android:layout_width=&quot;0dp&quot;
        android:layout_height=&quot;150dp&quot; /&gt;


    &lt;Button
        android:id=&quot;@+id/button_first&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/next&quot;
        app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
        app:layout_constraintEnd_toEndOf=&quot;parent&quot;
        app:layout_constraintStart_toStartOf=&quot;parent&quot;
        app:layout_constraintTop_toBottomOf=&quot;@id/image_third&quot; /&gt;
&lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;"><pre class="notranslate">&lt;?<span class="pl-ent">xml</span><span class="pl-e"> version</span>=<span class="pl-s"><span class="pl-pds">"</span>1.0<span class="pl-pds">"</span></span><span class="pl-e"> encoding</span>=<span class="pl-s"><span class="pl-pds">"</span>utf-8<span class="pl-pds">"</span></span>?&gt;
&lt;<span class="pl-ent">androidx</span>.constraintlayout.widget.ConstraintLayout <span class="pl-e">xmlns</span><span class="pl-e">:</span><span class="pl-e">android</span>=<span class="pl-s"><span class="pl-pds">"</span>http://schemas.android.com/apk/res/android<span class="pl-pds">"</span></span>
    <span class="pl-e">xmlns</span><span class="pl-e">:</span><span class="pl-e">app</span>=<span class="pl-s"><span class="pl-pds">"</span>http://schemas.android.com/apk/res-auto<span class="pl-pds">"</span></span>
    <span class="pl-e">xmlns</span><span class="pl-e">:</span><span class="pl-e">tools</span>=<span class="pl-s"><span class="pl-pds">"</span>http://schemas.android.com/tools<span class="pl-pds">"</span></span>
    <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>match_parent<span class="pl-pds">"</span></span>
    <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>match_parent<span class="pl-pds">"</span></span>
    <span class="pl-e">tools</span><span class="pl-e">:</span><span class="pl-e">context</span>=<span class="pl-s"><span class="pl-pds">"</span>.FirstFragment<span class="pl-pds">"</span></span>&gt;

    &lt;<span class="pl-ent">TextView</span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">"</span>@+id/textview_first<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>wrap_content<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>wrap_content<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">text</span>=<span class="pl-s"><span class="pl-pds">"</span>@string/hello_first_fragment<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintEnd_toEndOf</span>=<span class="pl-s"><span class="pl-pds">"</span>parent<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintStart_toStartOf</span>=<span class="pl-s"><span class="pl-pds">"</span>parent<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintTop_toTopOf</span>=<span class="pl-s"><span class="pl-pds">"</span>parent<span class="pl-pds">"</span></span> /&gt;

    &lt;<span class="pl-ent">ImageView</span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintEnd_toEndOf</span>=<span class="pl-s"><span class="pl-pds">"</span>parent<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintStart_toStartOf</span>=<span class="pl-s"><span class="pl-pds">"</span>parent<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintTop_toBottomOf</span>=<span class="pl-s"><span class="pl-pds">"</span>@id/textview_first<span class="pl-pds">"</span></span>
        <span class="pl-e">tools</span><span class="pl-e">:</span><span class="pl-e">src</span>=<span class="pl-s"><span class="pl-pds">"</span>@drawable/ic_launcher_foreground<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">"</span>@+id/image_first<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">contentDescription</span>=<span class="pl-s"><span class="pl-pds">"</span>first<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>0dp<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>150dp<span class="pl-pds">"</span></span> /&gt;

    &lt;<span class="pl-ent">ImageView</span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintEnd_toEndOf</span>=<span class="pl-s"><span class="pl-pds">"</span>parent<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintStart_toStartOf</span>=<span class="pl-s"><span class="pl-pds">"</span>parent<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintTop_toBottomOf</span>=<span class="pl-s"><span class="pl-pds">"</span>@id/image_first<span class="pl-pds">"</span></span>
        <span class="pl-e">tools</span><span class="pl-e">:</span><span class="pl-e">src</span>=<span class="pl-s"><span class="pl-pds">"</span>@drawable/ic_launcher_foreground<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">"</span>@+id/image_second<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">contentDescription</span>=<span class="pl-s"><span class="pl-pds">"</span>second<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>0dp<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>150dp<span class="pl-pds">"</span></span> /&gt;

    &lt;<span class="pl-ent">ImageView</span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintEnd_toEndOf</span>=<span class="pl-s"><span class="pl-pds">"</span>parent<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintStart_toStartOf</span>=<span class="pl-s"><span class="pl-pds">"</span>parent<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintTop_toBottomOf</span>=<span class="pl-s"><span class="pl-pds">"</span>@id/image_second<span class="pl-pds">"</span></span>
        <span class="pl-e">tools</span><span class="pl-e">:</span><span class="pl-e">src</span>=<span class="pl-s"><span class="pl-pds">"</span>@drawable/ic_launcher_foreground<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">"</span>@+id/image_third<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">contentDescription</span>=<span class="pl-s"><span class="pl-pds">"</span>third<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>0dp<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>150dp<span class="pl-pds">"</span></span> /&gt;


    &lt;<span class="pl-ent">Button</span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">"</span>@+id/button_first<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_width</span>=<span class="pl-s"><span class="pl-pds">"</span>wrap_content<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">layout_height</span>=<span class="pl-s"><span class="pl-pds">"</span>wrap_content<span class="pl-pds">"</span></span>
        <span class="pl-e">android</span><span class="pl-e">:</span><span class="pl-e">text</span>=<span class="pl-s"><span class="pl-pds">"</span>@string/next<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintBottom_toBottomOf</span>=<span class="pl-s"><span class="pl-pds">"</span>parent<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintEnd_toEndOf</span>=<span class="pl-s"><span class="pl-pds">"</span>parent<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintStart_toStartOf</span>=<span class="pl-s"><span class="pl-pds">"</span>parent<span class="pl-pds">"</span></span>
        <span class="pl-e">app</span><span class="pl-e">:</span><span class="pl-e">layout_constraintTop_toBottomOf</span>=<span class="pl-s"><span class="pl-pds">"</span>@id/image_third<span class="pl-pds">"</span></span> /&gt;
&lt;/<span class="pl-ent">androidx</span>.constraintlayout.widget.ConstraintLayout&gt;</pre></div>

<p dir="auto"><strong>Stack trace / LogCat</strong>: No errors</p>
<p dir="auto"><strong>Screenshot</strong>:</p>

<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/7944013/185390106-2eaddc6e-a9c9-4d4c-8089-0bc882ff1573.png"><img src="https://user-images.githubusercontent.com/7944013/185390106-2eaddc6e-a9c9-4d4c-8089-0bc882ff1573.png" alt="Screenshot_20220818_140300" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Example image</strong>:<br>
As GitHub doesn't support HEIC attachments I had to zip it.<br>
<a href="https://github.com/bumptech/glide/files/9373645/example_image.zip">example_image.zip</a></p>
<p dir="auto">Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface</p>
<p dir="auto">W/ExifInterface: Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface.<br>
<a href="http://java.io/" rel="nofollow">java.io</a>.IOException: Invalid byte order: 4646<br>
at androidx.exifinterface.media.ExifInterface.readByteOrder(ExifInterface.java:6581)<br>
at androidx.exifinterface.media.ExifInterface.parseTiffHeaders(ExifInterface.java:6588)<br>
at androidx.exifinterface.media.ExifInterface.getRawAttributes(ExifInterface.java:5617)<br>
at androidx.exifinterface.media.ExifInterface.loadAttributes(ExifInterface.java:4583)<br>
at androidx.exifinterface.media.ExifInterface.(ExifInterface.java:4032)<br>
at androidx.exifinterface.media.ExifInterface.(ExifInterface.java:3983)<br>
at com.bumptech.glide.load.resource.bitmap.ExifInterfaceImageHeaderParser.getOrientation(ExifInterfaceImageHeaderParser.java:40)<br>
at com.bumptech.glide.load.resource.bitmap.ExifInterfaceImageHeaderParser.getOrientation(ExifInterfaceImageHeaderParser.java:53)<br>
at com.bumptech.glide.load.ImageHeaderParserUtils$4.getOrientation(ImageHeaderParserUtils.java:147)<br>
at com.bumptech.glide.load.ImageHeaderParserUtils.getOrientationInternal(ImageHeaderParserUtils.java:222)<br>
at com.bumptech.glide.load.ImageHeaderParserUtils.getOrientation(ImageHeaderParserUtils.java:142)<br>
at com.bumptech.glide.load.resource.bitmap.ImageReader$ByteBufferReader.getImageOrientation(ImageReader.java:166)<br>
at com.bumptech.glide.load.resource.bitmap.Downsampler.decodeFromWrappedStreams(Downsampler.java:330)<br>
at com.bumptech.glide.load.resource.bitmap.Downsampler.decode(Downsampler.java:285)<br>
at com.bumptech.glide.load.resource.bitmap.Downsampler.decode(Downsampler.java:187)<br>
at com.bumptech.glide.load.resource.bitmap.ByteBufferBitmapDecoder.decode(ByteBufferBitmapDecoder.java:28)<br>
at com.bumptech.glide.load.resource.bitmap.ByteBufferBitmapDecoder.decode(ByteBufferBitmapDecoder.java:12)<br>
at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:92)<br>
at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:70)<br>
at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:59)<br>
at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:76)<br>
at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:57)<br>
at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:535)<br>
at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:499)<br>
at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:485)<br>
at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:430)<br>
at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:394)<br>
at com.bumptech.glide.load.engine.DataCacheGenerator.onDataReady(DataCacheGenerator.java:100)<br>
at com.bumptech.glide.load.model.ByteBufferFileLoader$ByteBufferFetcher.loadData(ByteBufferFileLoader.java:62)<br>
at com.bumptech.glide.load.engine.DataCacheGenerator.startNext(DataCacheGenerator.java:77)<br>
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)<br>
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:277)<br>
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)<br>
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)<br>
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)<br>
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:413)<br>
at java.lang.Thread.run(Thread.java:764)<br>
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:372)</p>
<p dir="auto">Actually，It is not a bug from Android ExifInterface , but it is a bug of Glide, and happened in Webp image.<br>
1, Why the exception happened ?<br>
Before the exception happened,  I debug the code and find that  the image mime type check result is "unknown".<br>
I found that ,  the ExifInterfaceImageHeaderParser get wrong header data which like this " [70, 70, -86, 8, 0, 0, 87, 69, 66, 80, 86, ......." .<br>
Webp file starts with "RIFFxxxxWebpxxxx",  must start with "RIFF" four characters , but the start characters begin with "FF", and "RI"  is lost.</p>
<p dir="auto">2, Why "FF" and not "RIFF"<br>
First, I check the cache file,  and the header start with "RIFF" , so it is not the problem of image file.<br>
Then, check the code of getOrientation function , We know that there are two image header parsers do the work:<br>
DefaultImageHeaderParser<br>
ExifInterfaceImageHeaderParser<br>
Two parsers share one image file input stream object.<br>
The first parser DefaultImageHeaderParser call imageReader obj to get getUInt16, and check image number;<br>
Because it is webp file, so it is not DefaultImageHeaderParser's work, so return unknown and the next parser continue the work.</p>
<p dir="auto">While ExifInterfaceImageHeaderParser is working, but it does not do reset for the shared stream obj.<br>
Because, the first parser read one UInt16, 2 bytes, so the second parser read header buffer from position = 2, not  0.<br>
So, The begin 2 characters lost.<br>
Based on webp header def:<br>
<strong>RIFF Header - 32 bits representing the ASCII characters ‘R’ ‘I’ ‘F’ ‘F’<br>
File Size - 32 bits (uint32) representing the size of the file in bytes starting at offset 8. The maximum value of this field is 2^32 minus 10 bytes and thus the size of the whole file is at most 4GiB minus 2 bytes.<br>
‘WEBP’ - 32 bits representing the ASCII characters ‘W’ ‘E’ ‘B’ ‘P’</strong></p>
<p dir="auto">We know that, webp file type check, the first four characters are the key point.  So the mime type check failed.<br>
Then, exif info check run into unknown file type, and parser header based on JPEG, so throw the exception like :<br>
"W/ExifInterface: Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface. "</p>
<p dir="auto">Glide provide wrong stream byte data is the root cause. It is not the problem of ExifInterface.<br>
Of course, It is based on if you refer ExifInterface version = 1.2.0.<br>
Because ExifInterface support webp header parse from 1.2.0, maybe,  I found webp parsing code in 1.2.0 and not check earlier version.</p>
<p dir="auto">So the suggestion is that adding reset code for input stream before ExifInterfaceImageHeaderParser do any parsing action  in new version.</p>
<p dir="auto">I did this check with glide 4.13.1 and ExifInterface 1.2.0.</p>
<p dir="auto"><em>Originally posted by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/aaronKueng/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/aaronKueng">@aaronKueng</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="772885726" data-permission-text="Title is private" data-url="https://github.com/bumptech/glide/issues/4451" data-hovercard-type="issue" data-hovercard-url="/bumptech/glide/issues/4451/hovercard?comment_id=1082539668&amp;comment_type=issue_comment" href="https://github.com/bumptech/glide/issues/4451#issuecomment-1082539668">#4451 (comment)</a></em></p>