Jimp: Rotation command gives opposite results

Created on 24 Sep 2018  路  13Comments  路  Source: oliver-moran/jimp

I'm not sure if this is a bug or a change, but I recently updated Jimp again after a long time and have a issue with the rotate command.

When I use image.rotate(-3) I expect the image to be rotated 3 degrees anti-clockwise. Instead, it rotates clockwise.

A similar case happens when I use image.rotate(20), it rotates anti-clockwise instead of clockwise.

Basically I get the opposite result of what I expect...

  • Jimp Version: 0.5.3
bug

Most helpful comment

CURRENT SOLUTION
Been dealing with this issue since 0.2 so I have a solution for those that have been struggling with this. One solution is to call the .rotate function with the number of degrees you want but multiply it by -1, but the best solution to make this easier for the developer is to do the following:

  1. In your node_modules folder for your base project, you will find a folder called @jimp, in this folder, go to plugin-rotate, then to dist and finally open index.js
  2. Go to line 128, you will find the following code: advancedRotate.call(this, deg, mode, cb);. Simply change this line to advancedRotate.call(this, -deg, mode, cb);.

For some reason, the base calculation in the advancedRotate function does all the rotations anticlockwise rather that clockwise. I'd rather not mess with the base code but a simple solution like this is better than messing with everything else.

All 13 comments

@MerriemWeebster you're right. getting a PR to change this together. Lots of broken tests though!

@hipstersmoothie Any update on this? I'm facing the same issue. Also, I'm not sure why I'm getting a border around the rotated image. It can be seen in the repro given in #669. It would be great if this gets fixed in the next release.

@hipstersmoothie I can pick this up and would be happy to submit a PR 鉁岋笍

go for it! @omkar-joshi

just be warned about the tests though. lots of updating to do

Issues with this still occur

Exact same problem, no changes

@hipstersmoothie any luck with a solution?

CURRENT SOLUTION
Been dealing with this issue since 0.2 so I have a solution for those that have been struggling with this. One solution is to call the .rotate function with the number of degrees you want but multiply it by -1, but the best solution to make this easier for the developer is to do the following:

  1. In your node_modules folder for your base project, you will find a folder called @jimp, in this folder, go to plugin-rotate, then to dist and finally open index.js
  2. Go to line 128, you will find the following code: advancedRotate.call(this, deg, mode, cb);. Simply change this line to advancedRotate.call(this, -deg, mode, cb);.

For some reason, the base calculation in the advancedRotate function does all the rotations anticlockwise rather that clockwise. I'd rather not mess with the base code but a simple solution like this is better than messing with everything else.

@MerriemWeebster it's a bug that you could fix :D simply make a pr and everyone can benefit from your findings

@MerriemWeebster it's a bug that you could fix :D simply make a pr and everyone can benefit from your findings

Not sure what you mean by pr, but I did make a suggestion for a fix

CURRENT SOLUTION
Been dealing with this issue since 0.2 so I have a solution for those that have been struggling with this. One solution is to call the .rotate function with the number of degrees you want but multiply it by -1, but the best solution to make this easier for the developer is to do the following:

  1. In your node_modules folder for your base project, you will find a folder called @jimp, in this folder, go to plugin-rotate, then to dist and finally open index.js
  2. Go to line 128, you will find the following code: advancedRotate.call(this, deg, mode, cb);. Simply change this line to advancedRotate.call(this, -deg, mode, cb);.

For some reason, the base calculation in the advancedRotate function does all the rotations anticlockwise rather that clockwise. I'd rather not mess with the base code but a simple solution like this is better than messing with everything else.

Sorry for reopening and opening this multiple times, but just wanted to make sure that if anyone finds this issue, know that this solution still works, sometimes even I forget about it and google the issue and use my own answer after all the code changes when I update it. I do hope it can be looked into as to why this solution is needed in the first place and thus I will keep this issue open for those that may have a similar problem but are unable to make use of my solution.

Also keeping this open since I have not gotten a reply as to why such an issue occurs in the first place or for a permanent solution based on the fix I requested.

@MerriemWeebster it's a bug that you could fix :D simply make a pr and everyone can benefit from your findings

Not sure what you mean by pr, but I did make a suggestion for a fix

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sesirimarco picture sesirimarco  路  3Comments

laino picture laino  路  5Comments

haydenbleasel picture haydenbleasel  路  6Comments

tutyamxx picture tutyamxx  路  4Comments

alyyousuf7 picture alyyousuf7  路  3Comments