Skip to content

Rotation of uploaded images #5996

@alxnkt

Description

@alxnkt

Describe the bug (feature)
In Strapi of version beta.20 there is a new possibility - creation of thumbnails of images. This is very useful and convenient feature. Thank you. In previous versions I had to do it by my own with help of sharp package: I could resize and rotate an image according to EXIF orientation tag.
New upload plugin does not automatically rotate images, so photos from iphone with "portrait" orientation (orientation tag 6) appears with wrong rotation.
So I want to ask:

  1. Is there any way to "hook" upload process to rotate an image (or do some other manipulations)?
  2. Is there any way to choose necessary formats? For example, I need thumbnail and medium size, but I don't need large size, sometimes I don't even need original file.

Steps to reproduce the behavior

  1. Upload any image with EXIF orientation tag equaled 6 (photo from iphone with "portrait" orientation).
  2. Go to "Media Library".
  3. Ensure the image has improper rotation.

Expected behavior
I would like images to be properly rotated.

Screenshots
In Finder:
finder
In Media Library (the building "fell down"):
media

Code snippets
My implementation of auto rotation:

// sharp automatically rotates image according to orientation tag
const thumbnailBuffer = await sharp(file.path)
    .resize(300)
    .rotate()
    .toBuffer();

System

  • Node.js version: 13.13.0
  • NPM version: 6.14.4
  • Strapi version: 3.0.0-beta.20.1
  • Database: PostgreSQL 12.2
  • Operating system: MacOS Catalina 10.15.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: feature requestIssue suggesting a new featureseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solve

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions