Media Library doesn't read image dimensions if JPG has embedded thumbnail

Describe your question/issue in detail

Hi, I did a bunch of searching and couldn't find any other mention of this error. However, it's happened to us three times now, with images submitted by different photographers, so it feels like probably more than a one-off. I hope this is the right forum for what I believe to be a bug report, and I'm also curious if others have had this issue.

After some diagnostic work on my side, it appears that Prismic Media Library fails to read/store image dimensions for (at least some) JPEGs with embedded (IFD1) thumbnails. This has happened to us with images from a Nikon dSLR, and possibly other sources.

I've found three approaches to fix these images:

Crop/Resize using the Prismic image editor (for each image, by hand)
or
Open in an image editor and then export to JPEG
or
Remove the thumbnail from the file on the commandline: exiftool -ifd1:all= -ext jpg <filename>

The images containing embedded thumbnails import successfully; however, once added to a Prismic document, the image embeds with incorrect (default?) dimensions:

And the original image renders poorly in our image gallery component, whereas the modified image comes through great:

Impacted feature

Prismic Media Library

What steps have you taken to resolve this issue already?

Much trial-and-error, documented above

Errors

No error message appears at any time. The only indication of a problem is the incorrect image dimensions in the Prismic media library and page builder, and the incorrect aspect ratios in the rendered images.

Your Role

Developer

Steps to reproduce

I've attached the "before" and "after" images that I used to create this ticket. The only difference is that the "after" image was run through exiftool to remove the embedded thumbnail. To see this behavior in action, simply unzip and add one or both JPEGs to your Prismic Media Library, and observe.

Unmodified original:

rhino-magick-original.jpg.zip (9.2 MB)

Same file, after running exiftool -ifd1:all= -ext jpg "rhino-magick-original.jpg" -o "rhino-magick-exiftool.jpg" :

rhino-magick-exiftool.jpg.zip (9.1 MB)

We've added a `clean-images shell script to our image ingestion pipeline, and that's working for now, so, this isn't urgent for me.

Many thanks in advance for any insight!

Thanks so much for taking the time to investigate this and share such a detailed report @Chaf, this is really helpful! We’ll pass everything along to the team so they can take a closer look.