세로 이미지가 서버를 업로드 후 가로로 표시?! - Vertical image goes to Horizontal image ?!


#1

$ Project Case: Lucket

1. Problem

When user upload 1 vertical image of product, and click request

=> uploaded image rotated horizontally

2. Root cause

In image profile, there is a value named exif.orientation. This value define the right rotation of image.

For example, I checked the image that had problem.

Orientation value is 90°. That means this image should rotate 90° normally

=> App must regconize the orientation and rotate the image follow that value

3. result after modified source code

image


4. Code and reference

- Test video: https://youtu.be/Nr7i5LwOvho

- Reference: https://sirv.com/help/resources/rotate-photos-to-be-upright/

- Code (for React Native, just for reference)

function rotateImage(exifOrientation) {
  let degRotation;
  switch (exifOrientation) {
    case 3:
      degRotation = "180deg"
      break;
    case 4:
      degRotation = "180deg"
      break;
    case 5:
      degRotation = "90deg"
      break;
    case 6:
      degRotation = "90deg"
      break;
    case 7:
      degRotation = "270deg"
      break;
    case 8:
      degRotation = "270deg"
      break;
    default:
      degRotation = "0deg"
  }
  return degRotation;
}