A DEV Community article explains a common image bug. Phones often store photos sideways and add an EXIF Orientation tag (metadata inside the file) that tells viewers how to turn them upright. If server code resizes the stored pixels and ignores the tag, the result can be wrong.
The author tested a 400 × 300 file stored with Orientation 6, which means turn 90° clockwise. Upright, the photo is 300 × 400. Resizing it to 200 px wide with sharp, a Node.js image library, gave a sideways 200 × 150 image. The tag was gone, because sharp strips metadata by default. The correct result was 200 × 267.
Keeping the tag with keepMetadata() made EXIF-aware viewers show the image upright at 150 × 200. That is not the width requested, and programs that ignore EXIF, such as some email clients, still show it sideways. The fix is to call rotate() with no arguments, or autoOrient(), before resizing. The three correct runs gave byte-identical output.
Pillow, a Python library, behaves the same way. Its thumbnail() works on stored pixels, so you should call ImageOps.exif_transpose() first. By default it returns a new image. With in_place=True it changes the original and returns None. The author notes that sharp's resize fixes the width, while thumbnail((200, 200)) fits the image inside a box, so the sizes differ but both are correct.
The author lists where the bug hides: aspect-ratio checks, width and height attributes, square crops and srcset widths. In each case the code reads dimensions before orienting. The author tested Orientation 6 only, not the mirrored values, and did not test HEIC input.
Why it matters
If your site accepts uploads, photos taken on phones may be stored sideways. A pipeline that ignores this can produce thumbnails that look wrong. It can also feed wrong dimensions into layout code.
Wrong width and height attributes can cause layout shift, where content jumps as images load. That can hurt the experience on pages with user photos or product images. Checking orientation once, early, keeps every later step consistent.
Source: DEV Community. This brief summarises their reporting; read the original for the full detail.