Jimp: Automatic image orientation based on EXIF is broken

Created on 12 May 2019  路  14Comments  路  Source: oliver-moran/jimp

Expected Behavior

When processing any image, the intended orientation should be preserved.

Current Behavior

In the provided example, a portrait image gets saved in landscape. You can see the black bars that get added on left and right. The core image is oriented correctly inside, but the output file has the wrong dimensions.

Failure Information (for bugs)

Steps to Reproduce

  1. git clone https://github.com/mkondel/jimp-exif-text.git
  2. yarn
  3. yarn start
  4. look at input.jpg and output.jpg

Screenshots
I have screenshots in the repo linked above ^^.

Context

I am using Jimp with excellent result on AWS Lambda. This bug is not related to that at all, as it can be replicated locally.

  • Jimp Version: v0.6.4
  • Operating System: Linux (Fedora)
  • Node version: v8.12.0

Failure Logs

Most helpful comment

@oliver-moran I think this is broken again in v0.14.0 (maybe before)

All 14 comments

I am also experiencing this issue, which is quite crippling for any application that allows users to upload an image from their device and camera.

This issue has noting to do with the rotate function (yet). As in the sample code provided by @mkondel, simply loading and writing the image will already deform it.

I fixed my issue by using another lib called jpeg-autorotate. Please checkout my repo above for a working demo. I use this lib before JIMP to "burn in" the rotation.

const fileIn = fs.readFileSync('input.jpg')
const jo = require('jpeg-autorotate')
const {buffer} = await jo.rotate(fileIn, {quality: 30})
const image = await Jimp.read(buffer)

Not sure why @mkondel closed this, the problem is still present in JIMP 0.6.4 (the latest version as of this comment).

Can we get this ticket reopened to get a proper fix, without external workarounds?

I agree with @grnch : it would be great if this could be fixed in Jimp.

I've struggled with this for hours yesterday wondering what I was doing wrong.
jpeg-autorotate works but you have to add another module and understand how it works (for exemple it will throw an error (!) if no rotation has to be done so you need another code path to handle this case...).

It has been broken by https://github.com/oliver-moran/jimp/commit/829b7d22395e616e72493af020d823e7a34f1568 commit I suppose. In index.js the false flag has been added to rotate calls, which led to unchanging dimensions during rotation. I've opened PR

The fix is merged 馃帀 and was released in v0.8.5 馃殌

So can this ticket be closed?

@oliver-moran I think this is broken again in v0.14.0 (maybe before)

The same issue with v0.14.0

this issue with v0.16.1

Any news?

Still broken in v0.16.1

same here with v0.16.1

Still broken in 0.16.1.

Folks. The image rotation is not handled equally by each browser. There are even differences between OS'es for the same browser. It is possible that even with a working JS lib (jimp or other) the EXIF data will get stripped/ignored by the upload. As an example, on windows chrome I have to pre-process all my images locally with a shell script that applies EXIF rotation directly to the files.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

geethupriya picture geethupriya  路  15Comments

vinaymuthanna0727 picture vinaymuthanna0727  路  13Comments

Allaphy picture Allaphy  路  42Comments

Gustavo6046 picture Gustavo6046  路  15Comments

ahaus picture ahaus  路  35Comments