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


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


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

  await rotate(options);

View Other Posts Tagged - Javascript - Node