Exif Orientation Metadata

Recently, I found that photos taken with a phone were rotated 90 degrees counterclockwise when drawing PDFs using the pdf-lib.js library. After investigation, it turns out that the image is recorded with a rotated data grid that records each pixel. We can see it correctly in most image viewers because there is an Orientation metadata information that these image viewers use to determine whether and how to rotate the image for display, but some programs do not do this.