Skip to main content

How to Check Image Orientation in NodeJs?

In this article, we will explore different approaches to checking the orientation of an image file in Node.js. Specifically, we will compare two popular libraries, "sharp" and "image-size".

Sharp

To check if an image file is vertical or horizontal in Node.js, you can utilize the `sharp` package, which is a popular image processing library. Here's an example of how you can determine the orientation of an image file using `sharp`:

First, you need to install the `sharp` package by running the following command in your Node.js project directory:

How to Wait for Multiple Selectors to Be Loaded Using Puppeteer and NodeJs

To wait for multiple selectors to be loaded using Puppeteer and Node.js, you can make use of the `waitForSelector` function in conjunction with `Promise.all`. Here's an example of how you can accomplish this:
 

How to check if string starts with number in nodejs?

To check if a string starts with a number in Node.js, you can use a regular expression. 

Here's an example code snippet that checks if a string starts with a number:

const myString = "5abc";
const startsWithNumber = /^\d/.test(myString);

console.log(startsWithNumber); // true

In the code above, we first define a string `myString` that starts with the number 5. We then create a regular expression `/^\d/` that matches any string that starts with a digit (`\d`). 

How to remove property / key from an object in nodejs

In Node.js, you can remove a property or key from an object using the `delete` keyword.

Here's an example:

How to Remove Duplicate Strings from an Array in NodeJs

To remove string duplicates from an array in Node.js, you can use the `filter` method along with the `indexOf` method.

Here's an example: