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".


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 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 Search for HTML Code with Cheerio in NodeJs

Cheerio is a very popular tool for parsing HTML and XML in NodeJs. It is fast, flexible, and easy to use. Since it implements a subset of JQuery, it's easy to start using Cheerio if you're already familiar with JQuery.

Here is how to search for HTML code with Cheerio in NodeJs.

Searching by elements

To search for particular HTML code using Cheerio in Node.js, you can use the $ function to load the HTML string or file and then use CSS selectors to find the desired element or elements.

How to Check if Object is Empty in NodeJs?

In Node.js, you can check if an object is empty by using the Object.keys() method to get an array of the object's keys, and then checking the length of the array.

Here's an example:

const obj = {};

if (Object.keys(obj).length === 0) {
  console.log('Object is empty');
} else {
  console.log('Object is not empty');

In the above code, Object.keys(obj) returns an empty array because the obj object has no keys. So Object.keys(obj).length will be 0, indicating that the object is empty.