Hello,

when rotating an image with non zero origin, the result is different from my expectation.

- There is a bug for non quadratic images.
- A case differentiation for images with non zero origin could be useful.

## Example

initial conditions:

- the image is not quadratic (in my case 2048x2412)
- the x-origin is -2740
- the y-origin is 1206
- width and hight of the pixels are positive

result after rotating 90° right:

- the new size is 2415x2048
- the x-origin is 841
- the y-origin is -2740
- width and hight of the pixels are positive

expectation when rotating 90° right:

- the new size is 2415x2048
- the x-origin is 1206
- the y-origin is -2740
- the pixel width is negative
- the pixel height is positive

For rotating 90° left I get wrong results, too.

## Proposal

The wrong value for x-origin is a bug. The lines (right/left)

`double xOrigin = imp.getWidth()-1 - cal.yOrigin;`

double yOrigin = imp.getHeight()-1 - cal.xOrigin;

have to be corrected to

`double xOrigin = imp.getHeight()-1 - cal.yOrigin;`

double yOrigin = imp.getWidth()-1 - cal.xOrigin;

because **imp** is the image before rotating.

I think negative pixel sizes are only desired in special cases, like mine. Maybe one should consider to use negative values when the origin is not zero and keep positive values when the origin is zero.

What is your opinion about using negative pixel sizes?