Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite handling EXIF orientation — add tests, make it plugin-independent #875

Merged
merged 3 commits into from
Apr 14, 2020

Conversation

skalee
Copy link
Contributor

@skalee skalee commented Apr 14, 2020

What's Changing and Why

Handling EXIF orientation has been rewritten from scratch. In a result:

  • it no longer relies on plugins (flip, rotate, and others);
  • solves issues coming from plugins like black border (Rotation adds black border #721) in scope of EXIF rotation;
  • everything is performed in a single pass.

Pictures are now processed with bitmap transformation functions, which map pixels from source bitmap to correctly rotated one. Computational complexity is proportional to number of pixels in given picture.

Finally, tests for EXIF rotation are added in this pull request. They were missing so far.

What else might be affected

It somewhat addresses #873, but list of dependencies of rotate plugin is still unclear.

I suppose nothing breaks. Public API is unaffected.

Things to consider

Perhaps transformBitmap() should be promoted to public low-level API. Perhaps some plugins like flip can leverage it. For example, a whole flip vertically operation could be written as:

transformBitmap(
  img,
  img.getWidth(),
  img.getHeight(),
  (x,y) => [img.getWidth() - x - 1, y],
);

Tasks

  • Add tests
  • Update Documentation — not applicable IMO
  • Update jimp.d.ts — I am not sure if it's needed here, no exported method has been changed
  • Add SemVer Label — I don't know what should be done here, please advise
📦 Published PR as canary version: 0.10.2-canary.875.842.0

✨ Test out this PR locally via:

npm install @jimp/cli@0.10.2-canary.875.842.0
npm install @jimp/core@0.10.2-canary.875.842.0
npm install @jimp/custom@0.10.2-canary.875.842.0
npm install jimp@0.10.2-canary.875.842.0
npm install @jimp/plugin-blit@0.10.2-canary.875.842.0
npm install @jimp/plugin-blur@0.10.2-canary.875.842.0
npm install @jimp/plugin-circle@0.10.2-canary.875.842.0
npm install @jimp/plugin-color@0.10.2-canary.875.842.0
npm install @jimp/plugin-contain@0.10.2-canary.875.842.0
npm install @jimp/plugin-cover@0.10.2-canary.875.842.0
npm install @jimp/plugin-crop@0.10.2-canary.875.842.0
npm install @jimp/plugin-displace@0.10.2-canary.875.842.0
npm install @jimp/plugin-dither@0.10.2-canary.875.842.0
npm install @jimp/plugin-fisheye@0.10.2-canary.875.842.0
npm install @jimp/plugin-flip@0.10.2-canary.875.842.0
npm install @jimp/plugin-gaussian@0.10.2-canary.875.842.0
npm install @jimp/plugin-invert@0.10.2-canary.875.842.0
npm install @jimp/plugin-mask@0.10.2-canary.875.842.0
npm install @jimp/plugin-normalize@0.10.2-canary.875.842.0
npm install @jimp/plugin-print@0.10.2-canary.875.842.0
npm install @jimp/plugin-resize@0.10.2-canary.875.842.0
npm install @jimp/plugin-rotate@0.10.2-canary.875.842.0
npm install @jimp/plugin-scale@0.10.2-canary.875.842.0
npm install @jimp/plugin-shadow@0.10.2-canary.875.842.0
npm install @jimp/plugin-threshold@0.10.2-canary.875.842.0
npm install @jimp/plugins@0.10.2-canary.875.842.0
npm install @jimp/test-utils@0.10.2-canary.875.842.0
npm install @jimp/bmp@0.10.2-canary.875.842.0
npm install @jimp/gif@0.10.2-canary.875.842.0
npm install @jimp/jpeg@0.10.2-canary.875.842.0
npm install @jimp/png@0.10.2-canary.875.842.0
npm install @jimp/tiff@0.10.2-canary.875.842.0
npm install @jimp/types@0.10.2-canary.875.842.0
npm install @jimp/utils@0.10.2-canary.875.842.0
# or 
yarn add @jimp/cli@0.10.2-canary.875.842.0
yarn add @jimp/core@0.10.2-canary.875.842.0
yarn add @jimp/custom@0.10.2-canary.875.842.0
yarn add jimp@0.10.2-canary.875.842.0
yarn add @jimp/plugin-blit@0.10.2-canary.875.842.0
yarn add @jimp/plugin-blur@0.10.2-canary.875.842.0
yarn add @jimp/plugin-circle@0.10.2-canary.875.842.0
yarn add @jimp/plugin-color@0.10.2-canary.875.842.0
yarn add @jimp/plugin-contain@0.10.2-canary.875.842.0
yarn add @jimp/plugin-cover@0.10.2-canary.875.842.0
yarn add @jimp/plugin-crop@0.10.2-canary.875.842.0
yarn add @jimp/plugin-displace@0.10.2-canary.875.842.0
yarn add @jimp/plugin-dither@0.10.2-canary.875.842.0
yarn add @jimp/plugin-fisheye@0.10.2-canary.875.842.0
yarn add @jimp/plugin-flip@0.10.2-canary.875.842.0
yarn add @jimp/plugin-gaussian@0.10.2-canary.875.842.0
yarn add @jimp/plugin-invert@0.10.2-canary.875.842.0
yarn add @jimp/plugin-mask@0.10.2-canary.875.842.0
yarn add @jimp/plugin-normalize@0.10.2-canary.875.842.0
yarn add @jimp/plugin-print@0.10.2-canary.875.842.0
yarn add @jimp/plugin-resize@0.10.2-canary.875.842.0
yarn add @jimp/plugin-rotate@0.10.2-canary.875.842.0
yarn add @jimp/plugin-scale@0.10.2-canary.875.842.0
yarn add @jimp/plugin-shadow@0.10.2-canary.875.842.0
yarn add @jimp/plugin-threshold@0.10.2-canary.875.842.0
yarn add @jimp/plugins@0.10.2-canary.875.842.0
yarn add @jimp/test-utils@0.10.2-canary.875.842.0
yarn add @jimp/bmp@0.10.2-canary.875.842.0
yarn add @jimp/gif@0.10.2-canary.875.842.0
yarn add @jimp/jpeg@0.10.2-canary.875.842.0
yarn add @jimp/png@0.10.2-canary.875.842.0
yarn add @jimp/tiff@0.10.2-canary.875.842.0
yarn add @jimp/types@0.10.2-canary.875.842.0
yarn add @jimp/utils@0.10.2-canary.875.842.0

Do not rely on .rotate() and .mirror() methods, which are defined
in plugins.  Instead, implement bitmap transformation functions,
which then can be applied to move pixels around.  This approach has
two main benefits: no plugins are required, and everything happens
in one pass.
@skalee skalee force-pushed the exif-rotate-without-plugins branch from 28b386f to 0b0c586 Compare April 14, 2020 13:16
@hipstersmoothie hipstersmoothie added the patch Increment the patch version when merged label Apr 14, 2020
@hipstersmoothie hipstersmoothie merged commit b038cba into jimp-dev:master Apr 14, 2020
@hipstersmoothie
Copy link
Collaborator

🚀 PR was released in v0.10.2 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants