EXIF data is ignored when uploading images #1501

Closed
opened 2026-02-05 01:04:59 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @JetUni on GitHub (Jan 20, 2020).

Describe the bug
When inserting an image that has EXIF rotation data, the rotation of the image isn't respected in the output.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Upload an image with EXIF rotation data
  2. Insert into the page
  3. See error in preview

Expected behavior
The EXIF rotation data should be considered when uploading the image so that it will display correctly

Screenshots
image

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): 0.27.4
  • PHP Version: PHP 7.0.33-0ubuntu0.16.04.9
  • Hosting Method (Nginx/Apache/Docker): Nginx
Originally created by @JetUni on GitHub (Jan 20, 2020). **Describe the bug** When inserting an image that has EXIF rotation data, the rotation of the image isn't respected in the output. **Steps To Reproduce** Steps to reproduce the behavior: 1. Upload an image with EXIF rotation data 2. Insert into the page 3. See error in preview **Expected behavior** The EXIF rotation data should be considered when uploading the image so that it will display correctly **Screenshots** ![image](https://user-images.githubusercontent.com/1317221/72755258-50c60580-3b87-11ea-8d76-5213b5ba1f8f.png) **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): 0.27.4 - PHP Version: PHP 7.0.33-0ubuntu0.16.04.9 - Hosting Method (Nginx/Apache/Docker): Nginx
OVERLORD added the 🛠️ Enhancement🏭 Back-End labels 2026-02-05 01:04:59 +03:00
Author
Owner

@alexmannuk commented on GitHub (Aug 24, 2020):

I've tested this on my own setup with v0.29.3 using Apache on Ubuntu 18.04 with PHP 7.2.24 and images appear to display rotated correctly. Either this is fixed in later versions of BookStack or you need to make sure php-exif is installed on your web server.

@alexmannuk commented on GitHub (Aug 24, 2020): I've tested this on my own setup with v0.29.3 using Apache on Ubuntu 18.04 with PHP 7.2.24 and images appear to display rotated correctly. Either this is fixed in later versions of BookStack or you need to make sure php-exif is installed on your web server.
Author
Owner

@cod3monk commented on GitHub (Feb 19, 2022):

I encountered the same problem running v21.12.1 using the latest solidnerd/bookstack docker image.

As the docker container does not install the exif php extension (explicitly), I have installed it manually and it did not make any change on reuploaded files. Same for mbstring.

Example

Page where image is used: link (may have changed in the meantime)
Original file: link (with correct rotation included in EXIF data)
Scaled file: link (missing all EXIF data, including rotation)

Expected Behavior

Either

  • preserve exif rotational information or
  • rotate scaled image according to exif information.

https://github.com/Intervention/image/issues/886

@cod3monk commented on GitHub (Feb 19, 2022): I encountered the same problem running v21.12.1 using the latest [solidnerd/bookstack](https://github.com/solidnerd/docker-bookstack) docker image. As the docker container does not install the exif php extension (explicitly), I have installed it manually and it did not make any change on reuploaded files. Same for mbstring. ## Example Page where image is used: [link](https://wiki.betreiberverein.de/link/251#bkmrk--2) (may have changed in the meantime) Original file: [link](https://wiki.betreiberverein.de/uploads/images/gallery/2022-02/mzLiUt433rH6mlFd-20211008-201511.jpg) (with correct rotation included in EXIF data) Scaled file: [link](https://wiki.betreiberverein.de/uploads/images/gallery/2022-02/scaled-1680-/mzLiUt433rH6mlFd-20211008-201511.jpg) (missing all EXIF data, including rotation) ## Expected Behavior Either * *preserve exif rotational information* or * *rotate scaled image according to exif information*. ## Related https://github.com/Intervention/image/issues/886
Author
Owner

@ssddanbrown commented on GitHub (Mar 26, 2022):

Thanks @cod3monk.

Sounds like we should call orientate in our thumbnail generation chain to alter the image to match exif rotation.

Will assign to next feature release to check, and implement this route if found viable.

@ssddanbrown commented on GitHub (Mar 26, 2022): Thanks @cod3monk. Sounds like we should call [orientate](https://image.intervention.io/v2/api/orientate) in our thumbnail generation chain to alter the image to match exif rotation. Will assign to next feature release to check, and implement this route if found viable.
Author
Owner

@ssddanbrown commented on GitHub (Mar 26, 2022):

Okay, not as simple as hoped.

By the time the intervention image instance has been created from image data the orientation exif is lost. Happens when creating and export an image via gd in general. Not a simple thing to patch upstream either unfortunately.

Instead we'll likely have to manually convert the image data to a stream on our side then read the exif_read_data output and then copy Intervention's orientate logic to achieve the desired output.

@ssddanbrown commented on GitHub (Mar 26, 2022): Okay, not as simple as hoped. By the time the intervention image instance has been created from image data the orientation exif is lost. Happens when creating and export an image via `gd` in general. Not a simple thing to patch upstream either unfortunately. Instead we'll likely have to manually convert the image data to a stream on our side then read the [`exif_read_data`](https://www.php.net/manual/en/function.exif-read-data.php) output and then copy [Intervention's orientate logic](https://github.com/Intervention/image/blob/b734a4988b2148e7d10364b0609978a88d277536/src/Intervention/Image/Commands/OrientateCommand.php) to achieve the desired output.
Author
Owner

@ssddanbrown commented on GitHub (Mar 26, 2022):

If have now applied 55d61fceb2 which re-implements intervention's orientation based upon exif data from original image data.

This will be part of the next feature release so I'll therefore close this off.

@ssddanbrown commented on GitHub (Mar 26, 2022): If have now applied 55d61fceb2f70209c29e6cc0dab4087a2b7b4312 which re-implements intervention's orientation based upon exif data from original image data. This will be part of the next feature release so I'll therefore close this off.
Author
Owner

@EricChen1248 commented on GitHub (Sep 10, 2022):

Just leaving a comment for users who are stupid like me and still find it not working.

If you are using linuxserver.io's version of bookstack, you need to create a custom docker image off of it and add php8-exif, as this fix relies on that.

FROM lscr.io/linuxserver/bookstack:latest

RUN apk add php8-exif

It's likely the same for solidnerd's version, but I didn't test it.

@EricChen1248 commented on GitHub (Sep 10, 2022): Just leaving a comment for users who are stupid like me and still find it not working. If you are using linuxserver.io's version of bookstack, you need to create a custom docker image off of it and add php8-exif, as this fix relies on that. ``` FROM lscr.io/linuxserver/bookstack:latest RUN apk add php8-exif ``` It's likely the same for solidnerd's version, but I didn't test it.
Author
Owner

@Skillkiller commented on GitHub (Oct 13, 2024):

Just leaving a comment for users who are stupid like me and still find it not working.

If you are using linuxserver.io's version of bookstack, you need to create a custom docker image off of it and add php8-exif, as this fix relies on that.

Fixed by 248b8769b4

@Skillkiller commented on GitHub (Oct 13, 2024): > Just leaving a comment for users who are stupid like me and still find it not working. > > If you are using linuxserver.io's version of bookstack, you need to create a custom docker image off of it and add php8-exif, as this fix relies on that. Fixed by https://github.com/linuxserver/docker-bookstack/commit/248b8769b4cc04b9fe64bfc130c1b76efd5d9222
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1501