rotate-image

· 1 min read

I had been looking for an NPM package that allowed me to rotate an image by n degrees. To my surprise, I found packages that only supported rotation in multiples of 90.

I thought this would be an easy task and jumped into action. Boy! It was tough. I was using all my trigonometry lessons(finally) and found myself often on math.stackexchange. It felt so good when I finally got it working :D

You can see the code on GitHub

Install

  • Run npm install -g @astronomersiva/rotate-image.

Usage

(async () => {
  const rotate = require('rotate-image');
  const options = {
    src: 'hello.png',
    dest: 'rotated.png', // optional, defaults to `${src}-rotated`
    rotation: 60
  };

  await rotate(options);
})();

RSS FeedTwitterGitHubEmailToggle Dark Mode OnToggle Dark Mode OffLink